|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.molae.pipe.binop.ElementwiseIterator<E,S1,S2>
public class ElementwiseIterator<E,S1 extends E,S2>
Performs a binary operation on every pair of elements from two iterators. The first element from iterator 1 is computed with the first element from iterator 2, the second element from iterator 1 with the second element from iterator 2 and so on...
If the first iterator has more elements than the second its elements are returned at the end of this iterator.
If the second iterator has more elements than the first one the trailing elements are ignored.
| Constructor Summary | |
|---|---|
ElementwiseIterator(BinaryFunction<? super S1,? super S2,? extends E> operation,
Iterator<S1> iterator1,
Iterator<S2> iterator2)
Constructs a new ElementwiseIterator. |
|
| Method Summary | ||
|---|---|---|
Iterator<S1> |
getIterator1()
Returns the first underlying iterator. |
|
Iterator<S2> |
getIterator2()
Returns the second underlying iterator. |
|
BinaryFunction<? super S1,? super S2,? extends E> |
getOperation()
Returns the underlying binary function. |
|
boolean |
hasNext()
Returns true if the iteration has more elements. |
|
E |
next()
Returns the next element in the interation. |
|
void |
remove()
Removes from the underlying collection the last element returned by the iterator. |
|
static
|
sum(BinaryFunction<? super T,? super S,T> operation,
Iterator<S> it)
Sums up all elements of an iterator using the specified binary operation. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ElementwiseIterator(BinaryFunction<? super S1,? super S2,? extends E> operation,
Iterator<S1> iterator1,
Iterator<S2> iterator2)
operation - The operation to be used for computation.iterator1 - An iterator conaining the first arguments.iterator2 - An iterator conaining the second arguments.
NullPointerException - if any argument is null.| Method Detail |
|---|
public BinaryFunction<? super S1,? super S2,? extends E> getOperation()
public Iterator<S1> getIterator1()
public Iterator<S2> getIterator2()
public boolean hasNext()
true if the iteration has more elements.
This implementation returns true if the first iterator
has more elements.
hasNext in interface Iterator<E>true if the iteration has more elements.public E next()
hasNext first.
Then it performs the base operation on the next elements of the two
base iterators and returns the result.
If either iterator has no more elements the next element of the
other iterator is returned.
If both iterators have no more elements an exception is thrown.
next in interface Iterator<E>NoSuchElementException - iteration has no more elementspublic void remove()
remove in interface Iterator<E>UnsupportedOperationException - if one or both of the underlying
iterators' remove method is not supported.
IllegalStateException - if the next method has not
yet been called, or the remove method has already been
called after the last call to the next method
public static <T,S extends T> T sum(BinaryFunction<? super T,? super S,T> operation,
Iterator<S> it)
null is returned.
operation - The operation to be used for computation.it - iterator on which the computation is performed.
NoSuchOperationException - if the iterator is empty and the binary
operation does not have an identity element.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||