All Packages Class Hierarchy This Package Previous Next Index
Class jdsl.core.ref.VCSVectorCircularSequence
java.lang.Object
|
+----jdsl.core.ref.VCSVectorCircularSequence
- public class VCSVectorCircularSequence
- extends Object
- implements CircularSequence
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.
-
VCSVectorCircularSequence()
- Constructs a new sequence with an initial capacity of 12.
-
VCSVectorCircularSequence(int)
- Constructs a new sequence with an underlying Vector of size
initialCapacity.
-
VCSVectorCircularSequence(int, int)
- Constructs a new sequence with an underlying Vector of size
initialCapacity.
-
after(Position)
- Gets the
Position after a given Position in
this CircularSequence.
-
before(Position)
- Gets the
Position before a given Position in
this CircularSequence
-
elements()
- Returns an
Enumeration of all the elements stored in this
container.
-
insertAfter(Position, Object)
- Inserts an element after a given position.
-
insertBefore(Position, Object)
- Inserts an element before a given position.
-
insertInitial(Object)
-
Inserts an element into an empty
CircularSequence.
-
isEmpty()
- Tests if this container is empty.
-
newContainer()
- Constructs a new
CircularNodeSequence.
-
positions()
- Returns all the positions in this container.
-
remove(Position)
- Removes the specified position.
-
replace(Position, Object)
-
Replace the element at the specified position with a new element.
-
size()
- Gets the number of elements in this container.
-
splice(Position, CircularSequence, Position)
-
Merges in another
CircularNodeSequence after a given
position.
-
split(Position, Position)
-
Snips out a chain of nodes from this
CircularSequence,
repairs this CircularSequence, and makes a new
CircularSequence with the snipped-out nodes.
-
startingPosition()
- Returns an arbitrary starting
Position in this
CircularSequence.
-
swap(Position, Position)
- Swaps the elements at two specified positions.
VCSVectorCircularSequence
public VCSVectorCircularSequence()
- Constructs a new sequence with an initial capacity of 12.
VCSVectorCircularSequence
public VCSVectorCircularSequence(int initialCapacity)
- Constructs a new sequence with an underlying Vector of size
initialCapacity.
VCSVectorCircularSequence
public VCSVectorCircularSequence(int initialCapacity,
int capacityIncrement)
- Constructs a new sequence with an underlying Vector of size
initialCapacity. Every time the Vector resizes, it
increases by capicityIncrement.
before
public Position before(Position successor) throws InvalidPositionException
- Gets the
Position before a given Position in
this CircularSequence
- Parameters:
- successor - Any
Position in this
Sequence.
- Returns:
- The
Position before successor.
- Throws: InvalidPositionException
- if
Position is
invalid, from a different container, or null.
- Throws: InvalidContainerException
- if this container has been
invalidated.
- See Also:
- splice
after
public Position after(Position predecessor) throws InvalidPositionException
- Gets the
Position after a given Position in
this CircularSequence.
- Parameters:
- predecessor - Any
Position in this
Sequence.
- Returns:
- The
Position before predecessor.
- Throws: InvalidPositionException
- if
Position is
invalid, from a different container, or null.
- Throws: InvalidContainerException
- if this container has been
invalidated.
- See Also:
- splice
startingPosition
public Position startingPosition() throws EmptyContainerException
- Returns an arbitrary starting
Position in this
CircularSequence. Note:There is no guarantee what
position this method returns, nor is there any guarantee that it remains
static.
- Returns:
- an arbitrary
Position in this container.
- Throws: EmptyContainerException
- if this container is empty.
- Throws: InvalidContainerException
- if this container has been
invalidated.
- See Also:
- splice
insertBefore
public Position insertBefore(Position p,
Object element) throws InvalidPositionException
- Inserts an element before a given position.
- Parameters:
- p - The
Position to insert before.
- element - The element to insert.
- Returns:
- the
Position holding the new element.
- Throws: InvalidPositionException
- if
Position is
invalid, from a different container, or null.
- Throws: InvalidContainerException
- if this container has been
invalidated.
- See Also:
- splice
insertAfter
public Position insertAfter(Position p,
Object element) throws InvalidPositionException
- Inserts an element after a given position.
- Parameters:
- p - The
Position to insert after.
- element - The element to insert.
- Returns:
- the
Position holding the new element.
- Throws: InvalidPositionException
- if
Position is
invalid, from a different container, or null.
- Throws: InvalidContainerException
- if this container has been
invalidated.
- See Also:
- splice
insertInitial
public Position insertInitial(Object element)
- Inserts an element into an empty
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.
- Parameters:
- element - Any
Object
- Returns:
-
Position of the object inserted
- Throws: NotEmptyContainerException
- if this sequence is not empty.
- Throws: InvalidContainerException
- if this container has been
invalidated.
- See Also:
- splice
remove
public Object remove(Position p) throws EmptyContainerException, InvalidPositionException
- Removes the specified position.
- Parameters:
- p - The
Position of the element after the element to
be removed.
- Returns:
- The removed element.
- Throws: EmptyContainerException
- If there are no elements in this
container.
- Throws: InvalidPositionException
- if
p is
null or not in this CircularSequence
- Throws: InvalidContainerException
- if this container has been
invalidated.
- See Also:
- splice
split
public CircularSequence split(Position inNewA,
Position inNewB) throws EmptyContainerException, InvalidPositionException
- Snips out a chain of nodes from this
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.
- Parameters:
- inNewA - Beginning of sequence of
Positions to be
removed from.
- inNewB - End of sequence of
Positions to be removed from
this CircularSequence.
- Returns:
- A new
CircularSequence holding inNewA,
inNewB, and all the Positions between them
- Throws: EmptyContainerException
- if this container is empty.
- Throws: InvalidPositionException
- if
inNewA or
inNewB is null, from a different container, or
of an incompatible type.
- Throws: InvalidContainerException
- if this container has been
invalidated.
- See Also:
- splice
splice
public void splice(Position afterWhich,
CircularSequence toMerge,
Position newSuccessor)
- Merges in another
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.
- Parameters:
- afterWhich -
Position after which to break this
CircularSequence
- toMerge -
CircularSequence to be spliced into this one
- newSuccessor -
Position from toMerge that will follow
Position afterWhich from this CircularSequence.
- Throws: InvalidContainerException
- If this container is invalid or if
toMerge is invalid or of an incompatible type.
- Throws: InvalidArgumentException
- if
toMerge is the same
container as splice is called on.
- Throws: InvalidPositionException
- if
afterWhich or
newSuccessor is either null, or of the wrong type.
- See Also:
- size
positions
public Enumeration positions()
- Returns all the positions in this container.
- Returns:
- An
Enumeration of all positions in this container.
- Throws: InvalidContainerException
- if this container has been
invalidated.
- See Also:
- splice
replace
public Object replace(Position p,
Object newElement) throws InvalidPositionException
- Replace the element at the specified position with a new element.
- Parameters:
- p - position at which the replacement is to occur
- newElement - new element to be stored at position p
- Returns:
- old element formerly stored at position p
- Throws: InvalidPositionException
- is thrown if the specified position
does not belong to the container or if the position is
null.
- Throws: InvalidContainerException
- if this container has been
invalidated.
- See Also:
- splice
swap
public void swap(Position a,
Position b) throws InvalidPositionException
- Swaps the elements at two specified positions.
- Parameters:
- p - first position participating in the swap.
- q - second position participating in the swap.
- Throws: InvalidPositionException
- if thrown if on or both of the specified
Positions does not belong to this implementation of
Container, or if either Position is
null.
- Throws: InvalidContainerException
- if this container has been
invalidated.
- See Also:
- splice
size
public int size() throws InvalidContainerException
- Gets the number of elements in this container. Each element is counted a
number of times according to its multiplicity. This is a linear time
operation.
- Throws: InvalidContainerException
- if this container has been
invalidated.
- See Also:
- splice
isEmpty
public boolean isEmpty()
- Tests if this container is empty.
- Returns:
-
true if this container is empty, false
otherwise.
- Throws: InvalidContainerException
- if this container has been
invalidated.
- See Also:
- splice
newContainer
public Container newContainer()
- Constructs a new
CircularNodeSequence.
- Returns:
- a new, empty container identical to this one.
- Throws: InvalidContainerException
- if this container has been
invalidated.
- See Also:
- splice
elements
public Enumeration elements()
- Returns an
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.
- Returns:
- An
Enumeration of all elements in the container.
- Throws: InvalidContainerException
- if this container has been
invalidated.
- See Also:
- splice
All Packages Class Hierarchy This Package Previous Next Index