Package nl.colorize.util.stats
Class TupleList<L,R>
- Type Parameters:
L
- Type of the first (left) element.R
- Type of the second (right) element.
- All Implemented Interfaces:
Iterable<Tuple<L,
,R>> Collection<Tuple<L,
,R>> List<Tuple<L,
,R>> SequencedCollection<Tuple<L,
R>>
Convenience class that can be used as a shorthand for creating a list of
Tuple
s.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a tuple to the list, then returns thisTupleList
instance.static <L,
R> TupleList <L, R> Creates aTupleList
by combining two lists.Returns a newTupleList
that will contain all tuples from this list, followed by all tuples fromother
.static <L,
R> TupleList <L, R> Factory method that creates a mutableTupleList
from an existing list of tuples.static <L,
R> TupleList <L, R> create()
Factory method that creates aTupleList
that is mutable and initially empty.delegate()
static <L,
R> TupleList <L, R> empty()
Creates a newTupleList
that is initially empty, and will throw anUnsupportedOperationException
when trying to modify it.void
forEach
(BiConsumer<L, R> callback) static <L,
R> TupleList <L, R> Factory method that creates a mutableTupleList
from a map.static <L,
R> TupleList <L, R> fromStream
(Stream<Tuple<L, R>> tuples) Factory method that creates a mutableTupleList
from an existing stream of tuples.getLeft()
Returns a list consisting of the left element of every tuple.getRight()
Returns a list consisting of the right element of every tuple.Creates a newTupleList
that contains the same elements as this one, but does not allow modification.inverse()
Returns a newTupleList
where every tuple is the inverse of the tuples in this list.<L2,
R2> TupleList <L2, R2> static <L,
R> TupleList <L, R> Deprecated.static <L,
R> TupleList <L, R> Factory method that creates a mutableTupleList
from existing tuples.Methods inherited from class com.google.common.collect.ForwardingList
add, addAll, equals, get, hashCode, indexOf, lastIndexOf, listIterator, listIterator, remove, set, standardAdd, standardAddAll, standardEquals, standardHashCode, standardIndexOf, standardIterator, standardLastIndexOf, standardListIterator, standardListIterator, standardSubList, subList
Methods inherited from class com.google.common.collect.ForwardingCollection
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, standardAddAll, standardClear, standardContains, standardContainsAll, standardIsEmpty, standardRemove, standardRemoveAll, standardRetainAll, standardToArray, standardToArray, standardToString, toArray, toArray
Methods inherited from class com.google.common.collect.ForwardingObject
toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.List
add, addAll, addFirst, addLast, clear, contains, containsAll, getFirst, getLast, isEmpty, iterator, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, size, sort, spliterator, toArray, toArray
-
Constructor Details
-
TupleList
public TupleList()
-
-
Method Details
-
delegate
-
add
-
append
Adds a tuple to the list, then returns thisTupleList
instance. This method is similar toadd(Object, Object)
but can be used for method chaining. -
getLeft
Returns a list consisting of the left element of every tuple. -
getRight
Returns a list consisting of the right element of every tuple. -
forEach
-
inverse
Returns a newTupleList
where every tuple is the inverse of the tuples in this list. Note the order of the tuples within the list will not change, this will only affect the tuples themselves. -
concat
-
map
-
immutable
Creates a newTupleList
that contains the same elements as this one, but does not allow modification. Attempting to modify the contents will result in anUnsupportedOperationException
. -
create
Factory method that creates aTupleList
that is mutable and initially empty. -
of
Factory method that creates a mutableTupleList
from existing tuples. -
of
Deprecated.Renamed tocopyOf(List)
, both because the new name is more descriptive and to be consistent with other collection classes.Factory method that creates a mutableTupleList
from an existing list of tuples. -
copyOf
Factory method that creates a mutableTupleList
from an existing list of tuples. -
fromStream
Factory method that creates a mutableTupleList
from an existing stream of tuples. -
fromMap
Factory method that creates a mutableTupleList
from a map. The map keys will act as the left element in each tuple, with the corresponding values acting as the right element. -
combine
Creates aTupleList
by combining two lists. Each tuple in the result will consist of an element from each list.- Throws:
IllegalArgumentException
- if the two lists do not have the same length.
-
empty
Creates a newTupleList
that is initially empty, and will throw anUnsupportedOperationException
when trying to modify it.
-
copyOf(List)
, both because the new name is more descriptive and to be consistent with other collection classes.