com.mchange.v1.util
Class IteratorUtils

java.lang.Object
  extended by com.mchange.v1.util.IteratorUtils

public final class IteratorUtils
extends Object


Field Summary
static Iterator EMPTY_ITERATOR
           
 
Method Summary
static boolean equivalent(Iterator ii, Iterator jj)
           
static void fillArray(Iterator ii, Object[] fillMe)
           
static void fillArray(Iterator ii, Object[] fillMe, boolean null_terminate)
          Fills an array with the contents of an iterator.
static Iterator oneElementUnmodifiableIterator(Object elem)
           
static Object[] toArray(Iterator ii, int array_size, Class componentClass)
           
static Object[] toArray(Iterator ii, int array_size, Class componentClass, boolean null_terminate)
           
static Object[] toArray(Iterator ii, int ii_size, Object[] maybeFillMe)
          Designed to help implement Collection.toArray(Object[] )methods...
static ArrayList toArrayList(Iterator ii, int initial_capacity)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_ITERATOR

public static final Iterator EMPTY_ITERATOR
Method Detail

oneElementUnmodifiableIterator

public static Iterator oneElementUnmodifiableIterator(Object elem)

equivalent

public static boolean equivalent(Iterator ii,
                                 Iterator jj)

toArrayList

public static ArrayList toArrayList(Iterator ii,
                                    int initial_capacity)

fillArray

public static void fillArray(Iterator ii,
                             Object[] fillMe,
                             boolean null_terminate)
Fills an array with the contents of an iterator. If the array is too small, it will contain the first portion of the iterator. If the array can contain more elements than the iterator, extra elements are left untouched, unless null_terminate is set to true, in which case the element immediately following the last from the iterator is set to null. (This method is intended to make it easy to implement Collection.toArray(Object[] oo) methods...

Parameters:
null_terminate - iff there is extra space in the array, set the element immediately after the last from the iterator to null.

fillArray

public static void fillArray(Iterator ii,
                             Object[] fillMe)

toArray

public static Object[] toArray(Iterator ii,
                               int array_size,
                               Class componentClass,
                               boolean null_terminate)
Parameters:
null_terminate - iff there is extra space in the array, set the element immediately after the last from the iterator to null.

toArray

public static Object[] toArray(Iterator ii,
                               int array_size,
                               Class componentClass)

toArray

public static Object[] toArray(Iterator ii,
                               int ii_size,
                               Object[] maybeFillMe)
Designed to help implement Collection.toArray(Object[] )methods... does the right thing if you can express an iterator and know the size of your Collection.