|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--jdsl.core.ref.VCSVectorCircularSequence
A CircularSequence implemented with a java.util.Vector. In particular, since Vector allocates a new array and copies the old array into the new one whenever it runs out of space, calls like vec_.insertElementAt(object,index) are NOT constant-time operations.
| Constructor Summary | |
VCSVectorCircularSequence()
Constructs a new sequence with an initial capacity of 12. |
|
VCSVectorCircularSequence(int initialCapacity)
Constructs a new sequence with an underlying Vector of size initialCapacity. |
|
VCSVectorCircularSequence(int initialCapacity,
int capacityIncrement)
Constructs a new sequence with an underlying Vector of size initialCapacity. |
|
| 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 VCSVectorCircularSequence()
public VCSVectorCircularSequence(int initialCapacity)
initialCapacity.
public VCSVectorCircularSequence(int initialCapacity,
int capacityIncrement)
initialCapacity. Every time the Vector resizes, it
increases by capicityIncrement.| Method Detail |
public Position before(Position successor)
throws InvalidPositionException
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
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
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
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
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.splicepublic Position insertInitial(java.lang.Object element)
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
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)
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:
sizepublic java.util.Enumeration positions()
Enumeration of all positions in this container.splice
public java.lang.Object replace(Position p,
java.lang.Object newElement)
throws InvalidPositionException
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
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
splicepublic boolean isEmpty()
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 | ||||||||