it.unimi.di.mg4j.index
Class IndexIterators

java.lang.Object
  extended by it.unimi.di.mg4j.index.IndexIterators

public class IndexIterators
extends Object

A class providing static methods and objects that do useful things with index iterators.


Nested Class Summary
protected static class IndexIterators.PositionsIterator
           
 
Field Summary
static IndexIterator[] EMPTY_ARRAY
           
 
Constructor Summary
protected IndexIterators()
           
 
Method Summary
static int[] positionArray(IndexIterator indexIterator)
          Returns the positions of an index iterator as an array.
static int[] positionArray(IndexIterator indexIterator, int[] position)
          Writes the positions of an index iterator into an array; if the array is not large enough, it will be reallocated using IntArrays.grow(int[], int).
static IntIterator positionIterator(IndexIterator indexIterator)
          Returns an IntIterator view of the positions of an index iterator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_ARRAY

public static final IndexIterator[] EMPTY_ARRAY
Constructor Detail

IndexIterators

protected IndexIterators()
Method Detail

positionArray

public static int[] positionArray(IndexIterator indexIterator)
                           throws IOException
Returns the positions of an index iterator as an array.

Note that this method just iterates IndexIterator.nextPosition(). If the method has already been called, the positions that have been already returned will be missing.

Returns:
an array containing the positions obtained by repeatedly calling IndexIterator.nextPosition().
Throws:
IOException

positionArray

public static int[] positionArray(IndexIterator indexIterator,
                                  int[] position)
                           throws IOException
Writes the positions of an index iterator into an array; if the array is not large enough, it will be reallocated using IntArrays.grow(int[], int).

Note that this method just iterates IndexIterator.nextPosition(). If the method has already been called, the positions that have been already returned will be missing.

Returns:
position, if it was large enough to contain all positions; a new, larger array otherwise.
Throws:
IOException

positionIterator

public static IntIterator positionIterator(IndexIterator indexIterator)
Returns an IntIterator view of the positions of an index iterator.

Note that this method just offers of a view of IndexIterator.nextPosition(). If the method has already been called, the positions that have been already returned will be missing.

Returns:
an IntIterator view of the positions obtained by repeatedly calling IndexIterator.nextPosition().