ISequence (interface)
Usage
Linkage:
-lopenxds_adt
To use the interface:
#include <openxds.adt/ISequence.h> using namespace openxds::adt;
Method Summary
Returns | Method-name | Parameters | Throws | |
---|---|---|---|---|
void | addFirst | E* element | ||
void | addFirst | E* element | ||
E* | removeFirst | NoSuchElementException* | ||
E* | removeLast | NoSuchElementException* | ||
E& | getFirst | NoSuchElementException* | ||
E& | getLast | NoSuchElementException* | ||
IPosition(E)* | insertFirst | E* element | ||
IPosition(E)* | insertLast | E* element | ||
IPosition(E)* | insertBefore | IPosition(E)& p | E* element | |
IPosition(E)* | insertAfter | IPosition(E)& p | E* element | |
E* | replace | IPosition(E)& p | E* element | |
E* | remove | IPosition(E)* p | ||
IPosition(E)* | first | NoSuchElementException* | ||
IPosition(E)* | last | NoSuchElementException* | ||
IPosition(E)* | prev | IPosition(E)& p | NoSuchElementException* | |
IPosition(E)* | previous | IPosition(E)& p | NoSuchElementException* | |
IPosition(E)* | next | IPosition(E)& p | NoSuchElementException* | |
IIterator(E)* | elements | |||
IPIterator(E)* | positions | |||
void | add | int rank | E* element | IndexOutOfBoundsException* |
E* | set | int rank | E* element | IndexOutOfBoundsException* |
E* | removeFrom | int rank | IndexOutOfBoundsException* | |
E& | get | int rank | IndexOutOfBoundsException* | |
int | rankOf | IPosition(E)& rank | ||
IPosition(E)* | atRank | int rank | IndexOutOfBoundsException* | |
bool | isEmpty | |||
long | size |
Methods
addFirst
void addFirst( E* element );
Parameters
element, to be inserted into the sequence.
Causes
The element to be added to the sequence at rank 0.
addLast
void addLast( E* element );
Parameters
element, to be inserted into the sequence.
Causes
The element to be added to the sequence at rank n, where n is the size of the sequence.
removeFirst
E* removeFirst() throw (NoSuchElementException*);
Returns
The element stored at rank 0 of the sequence.
Throws
NoSuchElementException, if the sequence is empty.
removeLast
E* removeLast() throw (NoSuchElementException*);
Returns
The element stored at rank n of the sequence, where n is the size of the sequence.
Throws
NoSuchElementException, if the sequence is empty.
getFirst
E& getFirst() throw (NoSuchElementException*);
Returns
A reference to the element stored at rank 0 of the sequence.
Throws
NoSuchElementException, if the sequence is empty.
getLast
E& getLast() throw (NoSuchElementException*);
Returns
A reference to the element stored at rank n of the sequence, where n is the size of the sequence.
Throws
NoSuchElementException, if the sequence is empty.
insertFirst
IPosition<E>* insertFirst( E* element );
Parameters
element, to be inserted into the list.
Returns
A new position that corresponds to the element's position in the list.
insertLast
IPosition<E>* insertLast( E* element );
Parameters
element, to be inserted into the list.
Returns
A new position that corresponds to the element's position in the list.
insertBefore
IPosition<E>* insertBefore( IPosition<E>& p, E* element );
Parameters
p, the position that the element is to be inserted before;
element, to be inserted into the list.
Returns
A new position that corresponds to the element's position in the list.
insertAfter
IPosition<E>* insertAfter( IPosition<E>& p, E* element );
Parameters
p, the position that the element is to be inserted after;
element, to be inserted into the list.
Returns
A new position that corresponds to the element's position in the list.
replace
E* replace( IPosition<E>& p, E* element );
Parameters
p, the position that the element is to be swapped into;
element, to be inserted into the list.
Returns
The previous element in that position.
remove
E* remove( IPosition<E>* p );
Parameters
p, the position that the element is to be removed from.
Returns
The element stored at the passed position.
first
IPosition<E>* first() throw (NoSuchElementException*);
Returns
The first position of the list.
last
IPosition<E>* last() throw (NoSuchElementException*);
Returns
The last position of the list.
previous (prev)
IPosition<E>* previous( IPosition<E>& p ) throw (NoSuchElementException*);
Parameters
p, a position in the list.
Returns
The position before p.
Throws
NoSuchElementException, if there is no position before p.
next
IPosition<E>* next( IPosition<E>& p ) throw (NoSuchElementException*);
Parameters
p, a position in the list.
Returns
The position after p.
Throws
NoSuchElementException, if there is no position after p.
elements
IIterator<E>* elements();
Returns
An element iterator that iterates over the list's elements.
positions
IPIterator<E>* positions();
Returns
A position iterator that iterates over the list's positions.
add
void add( int rank, E* element ) throw (IndexOutOfBoundsException*);
Parameters
rank, to add the element at, moving existing positions up one rank;
element, to be added at rank.
Throws
IndexOutOfBoundsException, if rank is greater than n, where n is the size of the sequence.
set
E* set( int rank, E* element ) throw (IndexOutOfBoundsException*);
Parameters
rank, of position whose element will replaced with element;
element, to be swapped into the position at rank.
Returns
The existing element in the position at rank.
Throws
IndexOutOfBoundsException, if rank is equal or greater than n, where n is the size of the sequence.
removeFrom
E* removeFrom( int rank ) throw (IndexOutOfBoundsException*);
Parameters
rank, of position to be removed.
Returns
The element that was stored in the removed position.
Throws
IndexOutOfBoundsException, if rank is equal or greater than n, where n is the size of the sequence.
get
E& get( int rank ) throw (IndexOutOfBoundsException*);
Parameters
rank, of a position in the sequence.
Returns
A reference to the element stored in the position at rank.
Throws
IndexOutOfBoundsException, if rank is equal or greater than n, where n is the size of the sequence.
rankOf
int rankOf( const IPosition<E>& p );
Parameters
p, a position in the sequence.
Returns
The rank of the passed position, p.
atRank
IPosition<E>* atRank( long rank ) throw (IndexOutOfBoundsException*);
Parameters
rank, the rank of a position in the sequence.
Returns
A new position instance corresponding to the underlying sequence node at rank.
Throws
IndexOutOfBoundsException, if rank is equal or greater than n, where n is the size of the sequence.
isEmpty
bool isEmpty();
Returns
TRUE, if the list is empty; otherwise FALSE.
size
long size();
Returns
The number of elements stored in the list.