byucc.jhdl.synth.graph
Class VertexVectorIterator

java.lang.Object
  extended bybyucc.jhdl.synth.graph.VectorIterator
      extended bybyucc.jhdl.synth.graph.VertexVectorIterator
All Implemented Interfaces:
GenericIterator, IndexedIterator, IndexedVertexIterator, VertexIterator

public class VertexVectorIterator
extends VectorIterator
implements IndexedVertexIterator

A class to allow a GenericIterator for Vertex objects in a VertexVector. This class simply extends VectorIterator. The constructor guarantees that this will only be constructed with a VertexVector. The VertexIterator interface is also implemented which has some convenient methods for saving class casts as well as performing graph cleanup when deleting vertices.

Author:
Carl Worth

Constructor Summary
VertexVectorIterator(VertexVector vertices)
          Construct a new VertexVectorIterator from an existing VertexVector.
 
Method Summary
 boolean deleteElt()
          Delete the object currently pointed at by the iterator.
 boolean deleteEltAt(int index)
          Delete the Vertex that has the given index.
 boolean deleteVertex()
          Delete the current vertex.
 boolean deleteVertexAt(int index)
          Delete the Vertex that has the given index
 Vertex getVertex()
          Get the Vertex at which the Iterator currently points.
 Vertex getVertexAt(int index)
          Get the Vertex that has the given index.
 
Methods inherited from class byucc.jhdl.synth.graph.VectorIterator
first, getElt, getEltAt, isValid, last, moveTo, moveTo, next, prev, size, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface byucc.jhdl.synth.graph.IndexedIterator
getEltAt, moveTo, size
 
Methods inherited from interface byucc.jhdl.synth.graph.GenericIterator
first, getElt, isValid, last, moveTo, next, prev
 

Constructor Detail

VertexVectorIterator

public VertexVectorIterator(VertexVector vertices)
Construct a new VertexVectorIterator from an existing VertexVector.

Method Detail

getVertex

public Vertex getVertex()
Get the Vertex at which the Iterator currently points.

Specified by:
getVertex in interface VertexIterator
Returns:
the current Vertex

getVertexAt

public Vertex getVertexAt(int index)
Get the Vertex that has the given index. (The current pointer will not be moved.)

Specified by:
getVertexAt in interface IndexedVertexIterator
Parameters:
index - an index in the range of 0 <= index < size()
Returns:
the Vertex 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. This call will remove the current Vertex from its graph as well as from this iterator's series of elements.

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.

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

deleteEltAt

public boolean deleteEltAt(int index)
Delete the Vertex that has the given index. This call will remove the Vertex at the given index from its graph as well as from this iterator's vector.

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
Overrides:
deleteEltAt in class VectorIterator
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 Vertex was deleted false if the index is out of bounds

deleteVertex

public boolean deleteVertex()
Delete the current vertex.

This method is the same as deleteElt. I'm including it here to maintain naming consistencies. (ie. getElt & getVertex, deleteElt, & deleteVertex etc.)

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

deleteVertexAt

public boolean deleteVertexAt(int index)
Delete the Vertex that has the given index

This methid is the same as deleteEltAt. I'm including it here to maintain naming consistencies. (ie. getElt & getVertex, deleteElt, & deleteVertex etc.)

Specified by:
deleteVertexAt in interface IndexedVertexIterator
Parameters:
index - the index of the Vertex to delete index should be in the range 0 <= index < size()
Returns:
true if the object was deleted false if the current pointer is not valid.
See Also:
deleteEltAt


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