gov.sandia.cognition.math.matrix
Class VectorUnionIterator

java.lang.Object
  extended by gov.sandia.cognition.math.matrix.VectorUnionIterator
All Implemented Interfaces:
Iterator<TwoVectorEntry>

@CodeReview(reviewer="Jonathan McClain",
            date="2006-05-17",
            changesNeeded=false,
            comments="Looks fine.")
public class VectorUnionIterator
extends Object
implements Iterator<TwoVectorEntry>

Iterator that returns all nonzero entries for either underlying Vector

Since:
1.0
Author:
Kevin R. Dixon

Constructor Summary
VectorUnionIterator(Iterator<VectorEntry> firstIterator, Iterator<VectorEntry> secondIterator, TwoVectorEntry internalEntry)
          Creates a new instance of VectorUnionIterator
VectorUnionIterator(Vector first, Vector second)
          Creates a new instance of VectorUnionIterator.
 
Method Summary
protected  void advanceInternalIterators()
          Internal method for advancing the internal Iterators
 VectorEntry getFirstInternalEntry()
          getter for firstInternalEntry
 Iterator<VectorEntry> getFirstIterator()
          getter for firstIterator
 TwoVectorEntry getInternalEntry()
          getter for internalEntry
 VectorEntry getSecondInternalEntry()
          getter for secondInternalEntry
 Iterator<VectorEntry> getSecondIterator()
          getter for secondIterator
 boolean hasNext()
           
 TwoVectorEntry next()
           
 void remove()
           
 boolean safeFirstNext()
          Try to advance the first entry...
 boolean safeSecondNext()
          Try to advance the second entry...
 void setFirstInternalEntry(VectorEntry firstInternalEntry)
          setter for firstInternalEntry
 void setFirstIterator(Iterator<VectorEntry> firstIterator)
          setter for firstIterator
 void setInternalEntry(TwoVectorEntry internalEntry)
          setter for internalEntry
 void setSecondInternalEntry(VectorEntry secondInternalEntry)
          setter for secondInternalEntry
 void setSecondIterator(Iterator<VectorEntry> secondIterator)
          setter for secondIterator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VectorUnionIterator

public VectorUnionIterator(Vector first,
                           Vector second)
Creates a new instance of VectorUnionIterator.

Parameters:
first - The first Vector.
second - The second Vector.

VectorUnionIterator

public VectorUnionIterator(Iterator<VectorEntry> firstIterator,
                           Iterator<VectorEntry> secondIterator,
                           TwoVectorEntry internalEntry)
Creates a new instance of VectorUnionIterator

Parameters:
firstIterator - Iterator from the first Vector
secondIterator - Iterator from the second Vector
internalEntry - TwoVectorEntry that represents entries from both Vectors
Method Detail

advanceInternalIterators

protected void advanceInternalIterators()
Internal method for advancing the internal Iterators


safeFirstNext

public boolean safeFirstNext()
Try to advance the first entry... if the iterator throws an exception, then there are no more elements in the vector, so just null out the entry

Returns:
true if next was valid, false otherwise

safeSecondNext

public boolean safeSecondNext()
Try to advance the second entry... if the iterator throws an exception, then there are no more elements in the vector, so just null out the entry

Returns:
true if next was valid, false otherwise

getFirstIterator

public Iterator<VectorEntry> getFirstIterator()
getter for firstIterator

Returns:
Iterator from the first Vector

setFirstIterator

public void setFirstIterator(Iterator<VectorEntry> firstIterator)
setter for firstIterator

Parameters:
firstIterator - Iterator from the first Vector

getSecondIterator

public Iterator<VectorEntry> getSecondIterator()
getter for secondIterator

Returns:
Iterator from the second Vector

setSecondIterator

public void setSecondIterator(Iterator<VectorEntry> secondIterator)
setter for secondIterator

Parameters:
secondIterator - Iterator from the second Vector

getInternalEntry

public TwoVectorEntry getInternalEntry()
getter for internalEntry

Returns:
TwoVectorEntry that represents both Vectors

setInternalEntry

public void setInternalEntry(TwoVectorEntry internalEntry)
setter for internalEntry

Parameters:
internalEntry - TwoVectorEntry that represents entries from both Vectors

getFirstInternalEntry

public VectorEntry getFirstInternalEntry()
getter for firstInternalEntry

Returns:
VectorEntry from the first Vector

setFirstInternalEntry

public void setFirstInternalEntry(VectorEntry firstInternalEntry)
setter for firstInternalEntry

Parameters:
firstInternalEntry - VectorEntry from the first Vector

getSecondInternalEntry

public VectorEntry getSecondInternalEntry()
getter for secondInternalEntry

Returns:
VectorEntry from the second Vector

setSecondInternalEntry

public void setSecondInternalEntry(VectorEntry secondInternalEntry)
setter for secondInternalEntry

Parameters:
secondInternalEntry - VectorEntry from the second Vector

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<TwoVectorEntry>

next

public TwoVectorEntry next()
Specified by:
next in interface Iterator<TwoVectorEntry>

remove

public void remove()
Specified by:
remove in interface Iterator<TwoVectorEntry>