/**
  * Gets a list based on an iterator.
  * <p>
  * As the wrapped Iterator is traversed, an ArrayList of its values is
  * created. At the end, the list is returned.
  *
  * @param iterator  the iterator to use, not null
  * @param estimatedSize  the initial size of the ArrayList
  * @return a list of the iterator contents
  * @throws NullPointerException if iterator parameter is null
  * @throws IllegalArgumentException if the size is less than 1
  */
 public static java.util.List<Object> toList(java.util.Iterator<Object> iterator, int estimatedSize)
 {
     if (iterator == null)
     {
         throw new java.lang.NullPointerException("Iterator must not be null");
     }
     if (estimatedSize < 1)
     {
         throw new java.lang.IllegalArgumentException("Estimated size must be greater than 0");
     }
     java.util.List<Object> list = new java.util.ArrayList<Object>(estimatedSize);
     while (iterator.hasNext())
     {
         list.add(iterator.next());
     }
     return list;
 }
Ejemplo n.º 2
0
 private static IEnumerable ToEnumer(java.util.Iterator enumeration)
 {
     List<object> list = new List<object>();
     while (enumeration.hasNext())
     {
         list.Add(enumeration.next());
     }
     return list;
 }
			protected override javax.imageio.spi.ImageReaderWriterSpi GetNext(java.util.Iterator iter) {
				imageio.ImageWriter w = (imageio.ImageWriter) iter.next ();
				return w.getOriginatingProvider ();
			}
		private static ImageCodec CreateWriter(java.util.Iterator iter) {
			if ( !iter.hasNext() )
				return null;
			
			ImageCodec imageCodec = new ImageCodec();
			imageCodec.NativeWriter = (imageio.ImageWriter) iter.next();
			return imageCodec;
		}
 /**
  * Adds all elements in the iteration to the given collection.
  *
  * @param collection  the collection to add to, must not be null
  * @param iterator  the iterator of elements to add, must not be null
  * @throws NullPointerException if the collection or iterator is null
  */
 public static void addAll(java.util.Collection<Object> collection, java.util.Iterator<Object> iterator)
 {
     while (iterator.hasNext())
     {
         collection.add(iterator.next());
     }
 }
 /**
  * Transforms all elements from the inputIterator with the given transformer
  * and adds them to the outputCollection.
  * <p>
  * If the input iterator or transformer is null, there is no change to the
  * output collection.
  *
  * @param inputIterator  the iterator to get the input from, may be null
  * @param transformer  the transformer to use, may be null
  * @param outputCollection  the collection to output into, may not be null
  * @return the outputCollection with the transformed input added
  * @throws NullPointerException if the output collection is null
  */
 public static java.util.Collection<Object> collect(java.util.Iterator<Object> inputIterator, Transformer transformer, java.util.Collection<Object> outputCollection)
 {
     if (inputIterator != null && transformer != null)
     {
         while (inputIterator.hasNext())
         {
             Object item = inputIterator.next();
             Object value = transformer.transform(item);
             outputCollection.add(value);
         }
     }
     return outputCollection;
 }
 private static Object index(java.util.Iterator<Object> iterator, int idx)
 {
     while (iterator.hasNext())
     {
         idx--;
         if (idx == -1)
         {
             return iterator.next();
         }
         else
         {
             iterator.next();
         }
     }
     return iterator;
 }