net.sf.molae.pipe.binop
Class ElementwiseCollection<E,S1 extends E,S2>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by net.sf.molae.pipe.binop.ElementwiseCollection<E,S1,S2>
All Implemented Interfaces:
Iterable<E>, Collection<E>

public final class ElementwiseCollection<E,S1 extends E,S2>
extends AbstractCollection<E>

Performs a binary operation on every pair of elements from two collections.


Constructor Summary
ElementwiseCollection(BinaryFunction<? super S1,? super S2,? extends E> operation, Collection<S1> base1, Collection<S2> base2)
          Constructs a computed collection from the specified collections and operation.
 
Method Summary
 Iterator<E> iterator()
           
static
<E,S1 extends E,S2>
ElementwiseCollection<E,S1,S2>
newInstance(BinaryFunction<? super S1,? super S2,E> operation, Collection<S1> base1, Collection<S2> base2)
          Constructs a computed collection from the specified collections and operation.
 int size()
           
 
Methods inherited from class java.util.AbstractCollection
add, addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Constructor Detail

ElementwiseCollection

public ElementwiseCollection(BinaryFunction<? super S1,? super S2,? extends E> operation,
                             Collection<S1> base1,
                             Collection<S2> base2)
Constructs a computed collection from the specified collections and operation.

Parameters:
operation - the underlying binary function
base1 - the collection containing the first operands of the underlying operation.
base2 - the collection containing the second operands of the underlying operation.
Throws:
NullPointerException - if any argument is null or if the specified operation has no permuted function.
Method Detail

newInstance

public static <E,S1 extends E,S2> ElementwiseCollection<E,S1,S2> newInstance(BinaryFunction<? super S1,? super S2,E> operation,
                                                                             Collection<S1> base1,
                                                                             Collection<S2> base2)
Constructs a computed collection from the specified collections and operation.

Parameters:
operation - the underlying binary function
base1 - the collection containing the first operands of the underlying operation.
base2 - the collection containing the second operands of the underlying operation.
Throws:
NullPointerException - if any argument is null or if the specified operation has no permuted function.
Since:
2.0

size

public int size()
Specified by:
size in interface Collection<E>
Specified by:
size in class AbstractCollection<E>

iterator

public Iterator<E> iterator()
Specified by:
iterator in interface Iterable<E>
Specified by:
iterator in interface Collection<E>
Specified by:
iterator in class AbstractCollection<E>