|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--jdsl.core.ref.CircularNodeSequence
A CircularSequence implemented with nodes. This container cannot check
container(), because container() is a linear time
operation.
CNSCircularNode| Constructor Summary | |
CircularNodeSequence()
Constructs a new, empty sequence. |
|
| Method Summary | |
Position |
after(Position predecessor)
Gets the Position after a given Position in
this CircularSequence. |
Position |
before(Position successor)
Gets the Position before a given Position in
this CircularSequence |
java.util.Enumeration |
elements()
Returns an Enumeration of all the elements stored in this
container. |
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. |
boolean |
isEmpty()
Tests if this container is empty. |
Container |
newContainer()
Constructs a new CircularNodeSequence. |
java.util.Enumeration |
positions()
Returns all the positions in this container. |
java.lang.Object |
remove(Position p)
Removes the specified position. |
java.lang.Object |
replace(Position p,
java.lang.Object newElement)
Replace the element at the specified position with a new element. |
int |
size()
Gets the number of elements in this container. |
void |
splice(Position afterWhich,
CircularSequence toMerge,
Position newSuccessor)
Merges in another CircularNodeSequence 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()
Returns an arbitrary starting Position in this
CircularSequence. |
void |
swap(Position a,
Position b)
Swaps the elements at two specified positions. |
| Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Constructor Detail |
public CircularNodeSequence()
| Method Detail |
public Position before(Position successor)
throws InvalidPositionException,
InvalidContainerException
Position before a given Position in
this CircularSequencesuccessor - Any Position in this
Sequence.Position before successor.Position is
invalid, from a different container, or null.splice
public Position after(Position predecessor)
throws InvalidPositionException,
InvalidContainerException
Position after a given Position in
this CircularSequence.predecessor - Any Position in this
Sequence.Position before predecessor.Position is
invalid, from a different container, or null.splice
public Position startingPosition()
throws EmptyContainerException,
InvalidContainerException
Position in this
CircularSequence. Note:There is no guarantee what
position this method returns, nor is there any guarantee that it remains
static.Position in this container.splice
public Position insertBefore(Position p,
java.lang.Object element)
throws InvalidPositionException,
InvalidContainerException
p - The Position to insert before.element - The element to insert.Position holding the new element.Position is
invalid, from a different container, or null.splice
public Position insertAfter(Position p,
java.lang.Object element)
throws InvalidPositionException,
InvalidContainerException
p - The Position to insert after.element - The element to insert.Position holding the new element.Position is
invalid, from a different container, or null.splice
public Position insertInitial(java.lang.Object element)
throws InvalidContainerException
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,
InvalidContainerException
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. This method takes constant 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
public void splice(Position afterWhich,
CircularSequence toMerge,
Position newSuccessor)
throws InvalidContainerException,
InvalidPositionException,
InvalidArgumentException
CircularNodeSequence after a given
position. That is, this CircularNodeSequence 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. This method takes constant 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:
size
public java.util.Enumeration positions()
throws InvalidContainerException
Enumeration of all positions in this container.splice
public java.lang.Object replace(Position p,
java.lang.Object newElement)
throws InvalidPositionException,
InvalidContainerException
p - position at which the replacement is to occurnewElement - new element to be stored at position pnull.splice
public void swap(Position a,
Position b)
throws InvalidPositionException,
InvalidContainerException
p - first position participating in the swap.q - second position participating in the swap.Positions does not belong to this implementation of
Container, or if either Position is
null.splice
public int size()
throws InvalidContainerException
splice
public boolean isEmpty()
throws InvalidContainerException
true if this container is empty, false
otherwise.splicepublic Container newContainer()
CircularNodeSequence.splicepublic java.util.Enumeration elements()
Enumeration of all the elements stored in this
container. Duplicated elements appear as many times as they are in the
container. Elements are returned in the order they are inserted.Enumeration of all elements in the container.splice
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||