net.sf.jga.algorithms
Class Append

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

public class Append
extends java.lang.Object

Algorithms that iterate over variable-length sets of inputs, ie, arrays, collections, or iterations, returning the combined contents of all inputs. For the common case, iterating over the combined contents of two inputs, the Merge class provides a type-safe wrapper around these algorithms. These algorithms are more flexible than the append forms of Merge, at the cost of being less type-safe.

NOTE: Use of these algorithms will result in type-safety warnings from the compiler: specifically "A generic array of ... is created for a varargs parameter". This is pretty much unavoidable given the mismatch in java between generics and arrays and given that variable length argument lists are converted to arrays by the compiler.

NOTE: Unlike most other classes in this package, Append does not support the form that puts the result of the algorithm into a collection passed as the last argument. The CollectionUtils class contains an append method that handles one input, and the Merge class contains an append method that handles two inputs. A varargs form of append to a given collection would be ambiguous in this class if it had the same name, and it would be ambiguous with the append in either CollectionUtils or Merge (or both) if all were statically imported. If you need to append three or more inputs to a given collection, the workaround is to call the appropriate method in this class to reduce the inputs to one, then use Collection.addAll (or CollectionUtils.append).

Copyright © 2008 David A. Hall


Nested Class Summary
static class Append.AppendIterable<T>
          Produces iterators that return the contents of a two-dimensional data structure
static class Append.AppendIterator<T>
          Iterator that returns the contents of a two-dimensional datastructure.
 
Constructor Summary
Append()
           
 
Method Summary
static
<T> java.lang.Iterable<? extends T>
append()
          Returns an empty iterable.
static
<T> java.lang.Iterable<? extends T>
append(java.lang.Iterable<? extends T>... inputs)
          Returns an Iterable that 'contains' all of the elements of the input(s)
static
<T> java.util.Iterator<? extends T>
append(java.util.Iterator<? extends T>... input)
          Returns an Iterator that will return elements from all of the iterators
static
<T> java.lang.Iterable<T>
append(T[]... ts)
          Returns all elements of each array
static
<T> java.lang.Iterable<T>
append(T[] ts)
          Returns all elements of each array
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Append

public Append()
Method Detail

append

public static <T> java.lang.Iterable<? extends T> append()
Returns an empty iterable. Special handling for the degenerate case.


append

public static <T> java.lang.Iterable<T> append(T[] ts)
Returns all elements of each array


append

public static <T> java.lang.Iterable<T> append(T[]... ts)
Returns all elements of each array


append

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


append

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



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