|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Sequence
A positional container whose elements are linearly organized. It is a generalization of stacks, queues, linked lists, and arrays.
For a Sequence, methods InspectableContainer.elements()
and InspectablePositionalContainer.positions()
are guaranteed to return iterators in first-to-last order.
InspectableSequence
,
PositionalContainer
Method Summary | |
---|---|
Position |
insertAfter(Position p,
java.lang.Object element)
Inserts an object after a position in the sequence. |
Position |
insertAtRank(int rank,
java.lang.Object element)
Inserts based on an integer rank similar to array indices. |
Position |
insertBefore(Position p,
java.lang.Object element)
Inserts an object before a position in the sequence. |
Position |
insertFirst(java.lang.Object element)
Inserts an object as first element of the sequence |
Position |
insertLast(java.lang.Object element)
Inserts an object as last element of the sequence. |
java.lang.Object |
remove(Position pos)
Removes and invalidates the specified position |
java.lang.Object |
removeAfter(Position pos)
Remove and invalidates the position after the position specified |
java.lang.Object |
removeAtRank(int rank)
Removes and invalidates the position at the specified rank |
java.lang.Object |
removeBefore(Position pos)
Removes and invalidates the position before the position specified. |
java.lang.Object |
removeFirst()
Removes and invalidates the first position of this. |
java.lang.Object |
removeLast()
Removes and invalidates the last position of this. |
Methods inherited from interface nz.ac.waikato.jdsl.core.api.InspectableSequence |
---|
after, atRank, before, first, isFirst, isLast, last, rankOf |
Methods inherited from interface nz.ac.waikato.jdsl.core.api.PositionalContainer |
---|
swapElements |
Methods inherited from interface nz.ac.waikato.jdsl.core.api.InspectablePositionalContainer |
---|
positions |
Methods inherited from interface nz.ac.waikato.jdsl.core.api.Container |
---|
newContainer, replaceElement |
Methods inherited from interface nz.ac.waikato.jdsl.core.api.InspectableContainer |
---|
contains, elements, isEmpty, size |
Method Detail |
---|
Position insertFirst(java.lang.Object element)
element
- Any java.lang.Object
Position
containing that element
,
which is now the first position in the sequence.Position insertLast(java.lang.Object element)
element
- Any java.lang.Object
Position
containing that element
,
which is now the last in the sequence.Position insertBefore(Position p, java.lang.Object element) throws InvalidAccessorException
p
- Position in this sequence before which to insert an
element.element
- Any java.lang.Objectelement
and before
Position p
.
InvalidAccessorException
- Thrown if p
is
not a valid position in this sequencePosition insertAfter(Position p, java.lang.Object element) throws InvalidAccessorException
p
- Position in this sequence after which to insert an
element.element
- Any java.lang.Objectelement
and after
Position p
.
InvalidAccessorException
- Thrown if p
is
not a valid position in this sequencePosition insertAtRank(int rank, java.lang.Object element) throws BoundaryViolationException
size() - 1
. It is valid to insert at any rank greater
than or equal to zero and less than or equal to size()
.
rank
- Rank that element
should have after insertion.element
- Any java.lang.Objectelement
in the sequence.
BoundaryViolationException
- if rank
exceeds
size()
or if 0 exceeds rank
java.lang.Object removeFirst() throws EmptyContainerException
EmptyContainerException
- if this sequence is emptyjava.lang.Object removeLast() throws EmptyContainerException
EmptyContainerException
- if this sequence is emptyjava.lang.Object remove(Position pos) throws InvalidAccessorException
pos
- the position to be removed
InvalidAccessorException
- if the specified position is
invalid or not belong to this container.java.lang.Object removeAfter(Position pos) throws BoundaryViolationException, InvalidAccessorException
pos
- a position
BoundaryViolationException
- if pos is the last position of this
sequence
InvalidAccessorException
- if the specified position is
invalid or not belong to this container.java.lang.Object removeBefore(Position pos) throws BoundaryViolationException, InvalidAccessorException
pos
- a position
BoundaryViolationException
- if pos is the first position of
this sequence.
InvalidAccessorException
- if the specified position is
invalid or not belong to this container.java.lang.Object removeAtRank(int rank) throws BoundaryViolationException
rank
- the rank of the position to be removed
BoundaryViolationException
- if rank is less than 0 or greater
than the size of this sequence
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |