Class IteratorUtils


  • public final class IteratorUtils
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.util.Iterator EMPTY_ITERATOR  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean equivalent​(java.util.Iterator ii, java.util.Iterator jj)  
      static void fillArray​(java.util.Iterator ii, java.lang.Object[] fillMe)  
      static void fillArray​(java.util.Iterator ii, java.lang.Object[] fillMe, boolean null_terminate)
      Fills an array with the contents of an iterator.
      static java.util.Iterator oneElementUnmodifiableIterator​(java.lang.Object elem)  
      static java.lang.Object[] toArray​(java.util.Iterator ii, int array_size, java.lang.Class componentClass)  
      static java.lang.Object[] toArray​(java.util.Iterator ii, int array_size, java.lang.Class componentClass, boolean null_terminate)  
      static java.lang.Object[] toArray​(java.util.Iterator ii, int ii_size, java.lang.Object[] maybeFillMe)
      Designed to help implement Collection.toArray(Object[] )methods...
      static java.util.ArrayList toArrayList​(java.util.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 java.util.Iterator EMPTY_ITERATOR
    • Method Detail

      • oneElementUnmodifiableIterator

        public static java.util.Iterator oneElementUnmodifiableIterator​(java.lang.Object elem)
      • equivalent

        public static boolean equivalent​(java.util.Iterator ii,
                                         java.util.Iterator jj)
      • toArrayList

        public static java.util.ArrayList toArrayList​(java.util.Iterator ii,
                                                      int initial_capacity)
      • fillArray

        public static void fillArray​(java.util.Iterator ii,
                                     java.lang.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​(java.util.Iterator ii,
                                     java.lang.Object[] fillMe)
      • toArray

        public static java.lang.Object[] toArray​(java.util.Iterator ii,
                                                 int array_size,
                                                 java.lang.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 java.lang.Object[] toArray​(java.util.Iterator ii,
                                                 int array_size,
                                                 java.lang.Class componentClass)
      • toArray

        public static java.lang.Object[] toArray​(java.util.Iterator ii,
                                                 int ii_size,
                                                 java.lang.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.