public interface Tuple extends java.lang.Iterable<java.lang.Object>, java.io.Serializable, java.lang.Comparable<Tuple>
Modifier and Type | Method and Description |
---|---|
Tuple |
append(java.lang.Object element)
Add an element to the end of a tuple.
|
boolean |
contains(java.lang.Object element)
Tests whether the tuple has an element equal to its argument.
|
boolean |
containsAll(java.lang.Iterable<?> element)
Tests whether the tuple has an element equal to its argument.
|
Tuple |
filter(ExecutionContext ctx,
FunctionDefinition fun)
Given a tuple and a predicate, returns a new tuple containing only the
elements that match the predicate.
|
Tuple |
filter(java.util.function.Predicate<java.lang.Object> fun)
Given a tuple and a
Predicate , returns a new tuple containing
only the elements that match the predicate. |
java.lang.Object |
get(int i)
Retrieve the object at one of a tuple's indices.
|
java.lang.Object |
head() |
int |
indexof(java.lang.Object element)
Searches for an element in a tuple, returning its index if found.
|
Tuple |
insert(int i,
java.lang.Object element)
Add an element to an arbitrary location within a tuple, moving all
elements after it down.
|
Tuple |
intersection(Tuple t)
Set arithmetic: compute intersection of set of tuple elements with set of
elements of another tuple.
|
boolean |
isEmpty() |
Tuple |
map(ExecutionContext ctx,
FunctionDefinition fun)
Maps a tuple to another same-length tuple by applying a function to each
element.
|
Tuple |
map(java.util.function.Function<java.lang.Object,java.lang.Object> fun)
Maps a tuple to another same-length tuple by applying a function to each
element.
|
java.lang.Object |
max(java.lang.Object def) |
Tuple |
mergeAfter(Tuple tuple)
Append elements of another tuple to the end of this tuple.
|
java.lang.Object |
min(java.lang.Object def) |
Tuple |
prepend(java.lang.Object element)
Add an element to the start of a tuple.
|
java.lang.Object |
reduce(ExecutionContext ctx,
java.lang.Object defVal,
FunctionDefinition fun)
Performs a reduction operation, that maps a tuple to a single value.
|
java.lang.Object |
reduce(java.lang.Object defVal,
java.util.function.BinaryOperator<java.lang.Object> fun)
Performs a reduction operation, that maps a tuple to a single value.
|
Tuple |
set(int i,
java.lang.Object element)
Replace an element in a tuple.
|
int |
size() |
Tuple |
sort() |
Tuple |
subtract(Tuple t)
Set arithmetic: compute which elements in this tuple are not in another
tuple.
|
Tuple |
subTuple(int i,
int j)
Produces a new Tuple containing the elements between the start and end
indices.
|
Tuple |
subTupleEnd(int i)
Produces a new Tuple containing all elements from i onward.
|
Tuple |
subTupleStart(int i)
Produces a new Tuple containing the first i elements.
|
Tuple |
tail() |
java.lang.Object[] |
toArray() |
Tuple |
union(Tuple t)
Set arithmetic: compute union of set of tuple elements with set of
elements of another tuple.
|
Tuple |
unwrap(int i)
For all elements that are tuples, substitute the ith sub-element.
|
Tuple |
zip(Tuple other)
Zips two tuples together, creating a Tuple of 2-ples.
|
Tuple append(java.lang.Object element)
element
- Element to be addedboolean contains(java.lang.Object element)
element
- Element to test whether it is equal to any element in the
tupleboolean containsAll(java.lang.Iterable<?> element)
element
- Element to test whether it is equal to any element in the
tupleTuple filter(ExecutionContext ctx, FunctionDefinition fun)
ctx
- the current execution contextfun
- the predicateTuple filter(java.util.function.Predicate<java.lang.Object> fun)
Predicate
, returns a new tuple containing
only the elements that match the predicate.fun
- the Predicate
Predicate
java.lang.Object get(int i)
i
- Zero-based index of the object to be retrievedjava.lang.Object head()
java.lang.ArrayIndexOutOfBoundsException
- if there are no elements in the tupleint indexof(java.lang.Object element)
element
- The object to be searched forTuple insert(int i, java.lang.Object element)
i
- Zero-based index at which the element is to be addedelement
- Element to be addedTuple intersection(Tuple t)
t
- tuple to take intersection withboolean isEmpty()
Tuple map(ExecutionContext ctx, FunctionDefinition fun)
ctx
- the current execution contextfun
- the function to applyTuple map(java.util.function.Function<java.lang.Object,java.lang.Object> fun)
fun
- the function to applyjava.lang.Object max(java.lang.Object def)
def
- the return in case max is not definedTuple mergeAfter(Tuple tuple)
tuple
- tuple to be addedjava.lang.Object min(java.lang.Object def)
def
- the return in case min is not definedTuple prepend(java.lang.Object element)
element
- Element to be addedjava.lang.Object reduce(ExecutionContext ctx, java.lang.Object defVal, FunctionDefinition fun)
ctx
- the current execution contextdefVal
- the value that will be returned if the tuple is emptyfun
- the BinaryOperator
that will be applied to each couple
of valuesjava.lang.Object reduce(java.lang.Object defVal, java.util.function.BinaryOperator<java.lang.Object> fun)
defVal
- the value that will be returned if the tuple is emptyfun
- the BinaryOperator
that will be applied to each couple
of valuesTuple set(int i, java.lang.Object element)
i
- Zero-based index at which the element is to be replacedelement
- Element to replace the current elementint size()
Tuple sort()
Tuple subtract(Tuple t)
t
- tuple to subtractTuple subTuple(int i, int j)
i
- start indexj
- end indexTuple subTupleEnd(int i)
i
- First element to take for new tupleTuple subTupleStart(int i)
i
- Number of elements to takeTuple tail()
java.lang.ArrayIndexOutOfBoundsException
- if there are no elements in the tuplejava.lang.Object[] toArray()
Tuple union(Tuple t)
t
- tuple to take union withTuple unwrap(int i)
i
- index of sub-element to substituteTuple zip(Tuple other)
other
- the tuple to zip this one with