|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A circular sequence stores elements in a ring, in other words it is
a sequence without a head or a tail. As a result, it is impossible to
generate a boundary violation in methods such as
before(Position)
and after(Position)
.
For a CircularSequence, methods InspectableContainer.elements()
and InspectablePositionalContainer.positions()
are guaranteed to return iterators in order. Which is to say
that these iterators return elements in order in which they would have
been accessed by repeated application of InspectableCircularSequence.after(.)
but do not guarantee that they start with InspectableCircularSequence.startingPosition()
.
InspectableCircularSequence
,
PositionalContainer
Method Summary | |
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 a given element into an empty circular sequence. |
java.lang.Object |
remove(Position pos)
Remove and invalidate the position specified |
java.lang.Object |
removeAfter(Position pos)
Remove and invalidate the position after the position specified |
java.lang.Object |
removeBefore(Position pos)
Remove the position before the position specified |
void |
setStartingPosition(Position p)
Sets the position that will be returned by method startingPosition() of InspectableCircularSequence |
void |
splice(Position afterWhich,
CircularSequence toMerge,
Position newSuccessor)
Merges in another CircularSequence (leaving it empty) 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. |
Methods inherited from interface jdsl.core.api.InspectableCircularSequence |
after, before, startingPosition |
Methods inherited from interface jdsl.core.api.InspectablePositionalContainer |
positions |
Methods inherited from interface jdsl.core.api.InspectableContainer |
contains, elements, isEmpty, size |
Methods inherited from interface jdsl.core.api.PositionalContainer |
swapElements |
Methods inherited from interface jdsl.core.api.Container |
newContainer, replaceElement |
Method Detail |
public void setStartingPosition(Position p) throws InvalidAccessorException, EmptyContainerException
InvalidAccessorException
- if p
is not a
valid position in this circular sequenceEmptyContainerException
- if there are no elements in
this circular sequencepublic Position insertBefore(Position p, java.lang.Object element) throws InvalidAccessorException
p
- A position in this sequenceelement
- Any objectPosition p
(the parameter)InvalidAccessorException
- if p
is not a valid position in this circular sequencepublic Position insertAfter(Position p, java.lang.Object element) throws InvalidAccessorException
p
- A position in this sequenceelement
- objectPosition p
(the parameter)InvalidAccessorException
- if p
is not a valid position in this circular sequencepublic Position insertInitial(java.lang.Object element) throws NonEmptyContainerException
element
- Any objectNonEmptyContainerException
- if there are no elements
in this circular sequence.public java.lang.Object remove(Position pos) throws InvalidAccessorException
pos
- the position to be removedpos
InvalidAccessorException
- if pos
is not a valid position in the circular sequence.public java.lang.Object removeAfter(Position pos) throws InvalidAccessorException
pos
- a positionpos
InvalidAccessorException
- if pos
is not a valid position in the circular sequence.public java.lang.Object removeBefore(Position pos) throws InvalidAccessorException
pos
- a positionpos
InvalidAccessorException
- if pos
is not a valid position in the circular sequence.public CircularSequence split(Position inNewA, Position inNewB) throws InvalidAccessorException
inNewA
- Start of sequence of Positions to be removed from
this CircularSequenceinNewB
- End of sequence of Positions to be removed from this
CircularSequenceInvalidAccessorException
- if neither inNewA
nor inNewB
is a valid positions contained in this
circular sequence.public void splice(Position afterWhich, CircularSequence toMerge, Position newSuccessor) throws InvalidAccessorException, InvalidContainerException
afterWhich
- Position after which to break this CircularSequencetoMerge
- CircularSequence to be spliced into this onenewSuccessor
- Position from toMerge that will follow Position
afterWhich in this CircularSequenceInvalidAccessorException
- if either
afterWhich
is not a valid position in this container or
newSuccessor
is not a valid position in toMerge
InvalidContainerException
- if toMerge is null, or
of the wrong implementation type, or equal to this circular sequence
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |