net.sf.molae.pipe.binop
Class ElementwiseList<E,S2>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
net.sf.molae.pipe.binop.ElementwiseList<E,S2>
- All Implemented Interfaces:
- Iterable<E>, Collection<E>, List<E>
public final class ElementwiseList<E,S2>
- extends AbstractList<E>
Performs a binary operation on every pair of elements from two lists.
Method Summary |
boolean |
add(E o)
Ensures that this collection contains the specified element
(optional operation). |
void |
clear()
Removes all of the elements from both base collections. |
E |
get(int index)
|
static
|
newInstance(BinaryFunction<E,? super S2,E> operation,
List<E> base1,
List<S2> base2)
Constructs a computed collection from the specified collections and
operation. |
E |
remove(int index)
|
E |
set(int index,
E element)
|
int |
size()
|
Methods inherited from class java.util.AbstractList |
add, addAll, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subList |
ElementwiseList
public ElementwiseList(BinaryFunction<E,? super S2,E> operation,
List<E> base1,
List<S2> base2)
- Constructs a computed collection from the specified collections and
operation.
- Parameters:
operation
- the underlying binary functionbase1
- the list containing the first operands of the
underlying operation.base2
- the list containing the second operands of the
underlying operation.
- Throws:
NullPointerException
- if any argument is null
or if the specified operation has no permuted function.
newInstance
public static <E,S2> ElementwiseList<E,S2> newInstance(BinaryFunction<E,? super S2,E> operation,
List<E> base1,
List<S2> base2)
- Constructs a computed collection from the specified collections and
operation.
- Parameters:
operation
- the underlying binary functionbase1
- the list containing the first operands of the
underlying operation.base2
- the list 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 interface List<E>
- Specified by:
size
in class AbstractCollection<E>
add
public boolean add(E o)
- Ensures that this collection contains the specified element
(optional operation).
- Specified by:
add
in interface Collection<E>
- Specified by:
add
in interface List<E>
- Overrides:
add
in class AbstractList<E>
- Parameters:
o
- element to be appended to this list.
- Returns:
true
if this collection changed as a result of the
call
- Throws:
UnsupportedOperationException
- if base operation has no inverse
operation
get
public E get(int index)
- Specified by:
get
in interface List<E>
- Specified by:
get
in class AbstractList<E>
set
public E set(int index,
E element)
- Specified by:
set
in interface List<E>
- Overrides:
set
in class AbstractList<E>
remove
public E remove(int index)
- Specified by:
remove
in interface List<E>
- Overrides:
remove
in class AbstractList<E>
clear
public void clear()
- Removes all of the elements from both base collections.
- Specified by:
clear
in interface Collection<E>
- Specified by:
clear
in interface List<E>
- Overrides:
clear
in class AbstractList<E>
- Throws:
UnsupportedOperationException
- depending on the base collections