|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Interface for a circular sequence, a sequence without head or tail
and without the possibility of boundary violations in prev(.)
and next(.). Note: After splicing a
CircularSequence into another sequence, the container that was
spliced becomes invalid, and will throw an
InvalidContainerException if any method is called on it.
splice| Method Summary | |
Position |
after(Position p)
Gets the Position after a given Position in
this CircularSequence |
Position |
before(Position p)
Gets the Position before a given Position in
this CircularSequence |
Position |
insertAfter(Position p,
java.lang.Object element)
Inserts an element after a given position. |
Position |
insertBefore(Position p,
java.lang.Object element)
Inserts an element before a given position. |
Position |
insertInitial(java.lang.Object element)
Inserts an element into an empty CircularSequence. |
java.lang.Object |
remove(Position p)
Removes the specified position. |
void |
splice(Position afterWhich,
CircularSequence toMerge,
Position newSuccessor)
Merges in another CircularSequence after a given position. |
CircularSequence |
split(Position inNewA,
Position inNewB)
Snips out a chain of nodes from this CircularSequence,
repairs this CircularSequence, and makes a new
CircularSequence with the snipped-out nodes. |
Position |
startingPosition()
Since there's no first() or last() in a circular
sequence, a method is needed that will give a position -- any position --
in the circular sequence, to get things started. |
| 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 before(Position p)
throws InvalidPositionException
Position before a given Position in
this CircularSequencep - Position of element in this sequencePosition of previous elementPosition is
invalid, from a different container, or null.splice
public Position after(Position p)
throws InvalidPositionException
Position after a given Position in
this CircularSequencep - Position of element in this sequencePosition of next elementPosition is
invalid, from a different container, or null.splice
public Position startingPosition()
throws EmptyContainerException
first() or last() in a circular
sequence, a method is needed that will give a position -- any position --
in the circular sequence, to get things started. No guarantees about what
position is returned.splice
public Position insertBefore(Position p,
java.lang.Object element)
throws InvalidPositionException
p - Position of element in this sequenceelement - Any java.lang.ObjectPosition of Object element, now stored
ahead of Position p (the parameter)p is null
or not in this CircularSequencesplice
public Position insertAfter(Position p,
java.lang.Object element)
throws InvalidPositionException
p - Position of element in this sequenceelement - Any java.lang.ObjectPosition of Object element, now stored
ahead of Position p (the parameter)p is null
or not in this CircularSequencesplice
public Position insertInitial(java.lang.Object element)
throws NotEmptyContainerException
CircularSequence. The
counterpart to startingPosition: intended for use only in an empty
circular sequence, where there is no position before or after which you
can insert.element - Any ObjectPosition of the object insertedsplice
public java.lang.Object remove(Position p)
throws EmptyContainerException,
InvalidPositionException
p - The Position of the element after the element to
be removed.p is
null or not in this CircularSequencesplice
public CircularSequence split(Position inNewA,
Position inNewB)
throws EmptyContainerException,
InvalidPositionException,
InvalidContainerException
CircularSequence,
repairs this CircularSequence, and makes a new
CircularSequence with the snipped-out nodes. If
inNewA==inNewB, only that one Position is removed from this
CircularSequence. @param inNewA Start of sequence of
Positions to be removed from this
CircularSequence. In structures that can implement this
method in constant time, size() will be implemented in linear
time.inNewA - Beginning of sequence of Positions to be
removed from.inNewB - End of sequence of Positions to be removed from
this CircularSequence.CircularSequence holding inNewA,
inNewB, and all the Positions between theminNewA or
inNewB is null, from a different container, or
of an incompatible type.splice,
SimpleContainer.size()
public void splice(Position afterWhich,
CircularSequence toMerge,
Position newSuccessor)
throws InvalidContainerException,
InvalidPositionException,
InvalidArgumentException
CircularSequence after a given position.
That is, this CircularSequence is snipped after a given
Position, and the merged-in CircularSequence is
snipped before a given Position. toMerge will be invalidated
after this method returns. In structures that can implement this method
in constant time, size() will be implemented in linear
time.afterWhich - Position after which to break this
CircularSequencetoMerge - CircularSequence to be spliced into this onenewSuccessor - Position from toMerge that will follow
Position afterWhich from this CircularSequence.toMerge is invalid or of an incompatible type.- InvalidArgumentException - if
toMerge is the same
container as splice is called on.- InvalidPositionException - if
afterWhich or
newSuccessor is either null, or of the wrong type. - See Also:
SimpleContainer.size()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||