|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Interface for a Sequence. A sequence is a positional container whose positions are linearly arranged and that supports both position-based and rank-based operations. It is a generalization of basic data structures such as stacks, queues, deques, arrays, vectors, and linked lists.
This interface defines Sequence by extending PositionalSequence with the rank-based methods rankOf, atRank and insertAtRank. However, it does not extend simple.api.RankedSequence as BookSequence does.
The enumerations returned by methods Container.elements() and PositionalContainer.positions() are guaranteed to give the elements/position in the same order as they are arranged in the sequence.
PositionalSequence,
PositionalContainer,
BookSequence,
simple.api.RankedSequence| Method Summary | |
Position |
atRank(int rank)
Return the position with the specified rank. |
Position |
insertAtRank(int rank,
java.lang.Object newElement)
Insert a new position into the sequence at the specified rank, and store the given element into the position. |
int |
rankOf(Position p)
Return the rank of the specified position. |
java.lang.Object |
removeAtRank(int rank)
Remove the position at the designated rank |
| Methods inherited from interface jdsl.core.api.PositionalSequence |
after,
before,
first,
insertAfter,
insertBefore,
insertFirst,
insertLast,
last,
remove,
removeAfter,
removeBefore,
removeFirst,
removeLast |
| Methods inherited from interface jdsl.core.api.PositionalContainer |
positions,
replace,
swap |
| Methods inherited from interface jdsl.core.api.Container |
elements,
newContainer |
| Methods inherited from interface jdsl.simple.api.SimpleContainer |
isEmpty,
size |
| Method Detail |
public Position atRank(int rank)
throws BoundaryViolationException
Note that the first position of a sequence has rank 0.
A BoundaryViolationException is thrown if rank < 0 or if rank > n - 1, where n is the size (number of positions) of the sequence.
rank - integer specifying the rank.
public int rankOf(Position p)
throws InvalidPositionException
p - position
public Position insertAtRank(int rank,
java.lang.Object newElement)
throws BoundaryViolationException
rank - rank that the new position should have. For
example, if rank = 0, the insertion is done at the beginning,
and if rank = n, where n is the old size (number of positions)
of the sequence, the insertion is done at the end.newElement - new element to be inserted.
public java.lang.Object removeAtRank(int rank)
throws BoundaryViolationException
rank - Index of the position to be removed
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||