net.sf.jga.algorithms
Class Flatten

java.lang.Object
  extended by net.sf.jga.algorithms.Flatten

public class Flatten
extends java.lang.Object

Algorithms that two-dimensional input, ie, arrays of arrays, collections of collections, etc.

Adapted from a suggestion by Beñat Gurmendi.

Copyright © 2008 David A. Hall


Constructor Summary
Flatten()
           
 
Method Summary
static
<T> java.lang.Iterable<T>
flatten(java.lang.Iterable<? extends java.lang.Iterable<? extends T>> input)
          Returns an Iterable that 'contains' all of the elements of the input(s)
static
<T,TCollection extends java.util.Collection<? super T>>
TCollection
flatten(java.lang.Iterable<? extends java.lang.Iterable<? extends T>> input, TCollection cout)
          Appends the values of all of the intpu to the output collection
static
<T> java.util.Iterator<T>
flatten(java.util.Iterator<? extends java.util.Iterator<? extends T>> input)
          Returns an Iterator that will return elements from all of the iterators
static
<T> java.lang.Iterable<T>
flatten(T[][] ts)
          Returns all elements of the 2d array
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Flatten

public Flatten()
Method Detail

flatten

public static <T> java.lang.Iterable<T> flatten(T[][] ts)
Returns all elements of the 2d array


flatten

public static <T> java.lang.Iterable<T> flatten(java.lang.Iterable<? extends java.lang.Iterable<? extends T>> input)
Returns an Iterable that 'contains' all of the elements of the input(s)


flatten

public static <T> java.util.Iterator<T> flatten(java.util.Iterator<? extends java.util.Iterator<? extends T>> input)
Returns an Iterator that will return elements from all of the iterators


flatten

public static <T,TCollection extends java.util.Collection<? super T>> TCollection flatten(java.lang.Iterable<? extends java.lang.Iterable<? extends T>> input,
                                                                                          TCollection cout)
Appends the values of all of the intpu to the output collection

Returns:
the output collection


Copyright © 2002-2006 David A. Hall. All Rights Reserved.