byucc.jhdl.synth.graph
Class VectorIterator

java.lang.Object
  extended bybyucc.jhdl.synth.graph.VectorIterator
All Implemented Interfaces:
GenericIterator, IndexedIterator
Direct Known Subclasses:
EdgeIterator, EnumerationIterator, VertexVectorIterator

public class VectorIterator
extends java.lang.Object
implements IndexedIterator

A simple object that contains a vector and implements the IndexedIterator interface for the objects in that vector.

Author:
Carl Worth

Constructor Summary
VectorIterator(java.util.Vector v)
          Construct a new VectorIterator from an existing Vector object.
 
Method Summary
 boolean deleteElt()
          Delete the object currently pointed at by the iterator.
 boolean deleteEltAt(int index)
          Delete the object that has the given index.
 GenericIterator first()
          Move this iterator's "pointer" to the first element in the series.
 java.lang.Object getElt()
          Retrieves the object currently pointed at by the iterator.
 java.lang.Object getEltAt(int index)
          Retrieves the object at the given index.
 boolean isValid()
          Checks if the iterator currently points to a valid item in the series.
 GenericIterator last()
          Move this iterator's "pointer" to the last element in the series.
 boolean moveTo(int index)
          Moves the iterator to the element with the given index.
 boolean moveTo(java.lang.Object elt)
          Moves the iterator to the specified element.
 GenericIterator next()
          Moves the iterator to the next element in the series.
 GenericIterator prev()
          Moves the iterator to the previous element in the series.
 int size()
          Returns the number of elements in the series.
 java.lang.String toString()
          Get a String representation of this VectorIterator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VectorIterator

public VectorIterator(java.util.Vector v)
Construct a new VectorIterator from an existing Vector object.

Method Detail

first

public GenericIterator first()
Move this iterator's "pointer" to the first element in the series.

Specified by:
first in interface GenericIterator
Returns:
this VectorIterator, (suitable for chaining)

last

public GenericIterator last()
Move this iterator's "pointer" to the last element in the series.

Specified by:
last in interface GenericIterator
Returns:
this VectorIterator, (suitable for chaining)

isValid

public boolean isValid()
Checks if the iterator currently points to a valid item in the series. This method will return false after calling next() when on the last item or after calling prev() when on the first item.

Specified by:
isValid in interface GenericIterator
Returns:
true if iterator points to a valid item, false otherwise.

next

public GenericIterator next()
Moves the iterator to the next element in the series.

Specified by:
next in interface GenericIterator
Returns:
this VectorIterator, (suitable for chaining)

prev

public GenericIterator prev()
Moves the iterator to the previous element in the series.

Specified by:
prev in interface GenericIterator
Returns:
this VectorIterator, (suitable for chaining)

moveTo

public boolean moveTo(java.lang.Object elt)
Moves the iterator to the specified element. The equality check to determine if elt is in the series uses the Object.equals() method which may be overriden.

Specified by:
moveTo in interface GenericIterator
Returns:
true if pointer was moved to object, false if the given element is not in the series. (If false then the current pointer's position is undefined. It may be invalid).

moveTo

public boolean moveTo(int index)
Moves the iterator to the element with the given index.

Specified by:
moveTo in interface IndexedIterator
Parameters:
index - an index in the range of 0 <= index < size()
Returns:
true if pointer was moved to the element at the given index, false if the given index is out of bounds.

getElt

public java.lang.Object getElt()
Retrieves the object currently pointed at by the iterator.

Specified by:
getElt in interface GenericIterator
Returns:
the current object in the series or null if current is inValid

getEltAt

public java.lang.Object getEltAt(int index)
Retrieves the object at the given index. (The current pointer will not be moved.)

Specified by:
getEltAt in interface IndexedIterator
Parameters:
index - an index in the range of 0 <= index < size()
Returns:
the object in the series with the given index, null if index is out of bounds.

deleteElt

public boolean deleteElt()
Delete the object currently pointed at by the iterator. After calling delete, this iterator's current "pointer" will be at an undefined position, (it may even be invalid). However, calling next() will move it to the element originally after the deleted element and calling prev() will move it to the element originally before element.

Also Note: Any modifications of the series of elements, (ie. deletes or modifications), other than through this iterator may cause undefined effects on the state of this iterator.

Finally, this method deletes the current element using Vector.removeElementAt(current) and then calls prev() to move the pointer to the correct place. Subclasses of VectorIterator may depend on this call to prev(), wcich can of course be overrriden.

Specified by:
deleteElt in interface GenericIterator
Returns:
true if the object was deleted false if the current pointer is not valid.

deleteEltAt

public boolean deleteEltAt(int index)
Delete the object that has the given index. After calling delete, this iterator's current "pointer" will not be moved. That is, if the object being deleted is not the "current" object then the pointer will still be pointing to the same element it was before the delete. If, however, the current object is deleted then the pointer will be at an undefined position, (it may even be invalid) -- however, calling next() will move it to the element originally after the deleted element and calling prev() will move it to the element originally before element.

Also Note: Any modifications of the series of elements, (ie. deletes or modifications), other than through this iterator may cause undefined effects on the state of this iterator.

Specified by:
deleteEltAt in interface IndexedIterator
Parameters:
index - the index of an element in the series to delete, index should be in the range 0 <= index < size()
Returns:
true if the object was deleted false if the index is out of bounds.

size

public int size()
Returns the number of elements in the series.

Specified by:
size in interface IndexedIterator
Returns:
number of elements in the series.

toString

public java.lang.String toString()
Get a String representation of this VectorIterator



Copyright ? 2006 Brigham Young University, Configurable Computing Laboratory. All Rights Reserved.