org.embl.ebi.escience.baclava.iterator
Class LockStepIterator

java.lang.Object
  extended by org.embl.ebi.escience.baclava.iterator.LockStepIterator
All Implemented Interfaces:
java.util.Iterator, ResumableIterator

public class LockStepIterator
extends java.lang.Object
implements ResumableIterator

Provides an Iterator that iterates over the contained iterators in lock step, incrementing all at the same time.

Author:
Tom Oinn

Constructor Summary
LockStepIterator()
           
LockStepIterator(ResumableIterator[] i)
           
 
Method Summary
 int[] getCurrentLocation()
          Get the current location by finding the longest current position array from all the child iterators and returning it.
 boolean hasNext()
          If the iterator isn't empty then all the iterators contained within it are the same length, can therefore just ask the first one
 java.lang.Object next()
          Returns an array of items created by calling the next() method of each contained iterator
 void remove()
          Calls to the remove operation are not allowed from this iterator
 void reset()
          Reset all the iterators
 int size()
          All iterators are the same size
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LockStepIterator

public LockStepIterator()

LockStepIterator

public LockStepIterator(ResumableIterator[] i)
Method Detail

reset

public void reset()
Reset all the iterators

Specified by:
reset in interface ResumableIterator

getCurrentLocation

public int[] getCurrentLocation()
Get the current location by finding the longest current position array from all the child iterators and returning it. This is because otherwise if we take the approach that the join iterator uses we end up with holes in the resultant collection structure caused by the redundant information.

Specified by:
getCurrentLocation in interface ResumableIterator

hasNext

public boolean hasNext()
If the iterator isn't empty then all the iterators contained within it are the same length, can therefore just ask the first one

Specified by:
hasNext in interface java.util.Iterator

remove

public void remove()
            throws java.lang.UnsupportedOperationException
Calls to the remove operation are not allowed from this iterator

Specified by:
remove in interface java.util.Iterator
Throws:
java.lang.UnsupportedOperationException

next

public java.lang.Object next()
                      throws java.util.NoSuchElementException
Returns an array of items created by calling the next() method of each contained iterator

Specified by:
next in interface java.util.Iterator
Throws:
java.util.NoSuchElementException

size

public int size()
All iterators are the same size

Specified by:
size in interface ResumableIterator