Class TupleList<L,R>

java.lang.Object
com.google.common.collect.ForwardingObject
com.google.common.collect.ForwardingCollection<Tuple<L,R>>
com.google.common.collect.ForwardingList<Tuple<L,R>>
nl.colorize.util.stats.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>>

public class TupleList<L,R> extends com.google.common.collect.ForwardingList<Tuple<L,R>>
Convenience class that can be used as a shorthand for creating a list of Tuples.
  • Constructor Details

    • TupleList

      public TupleList()
  • Method Details

    • delegate

      protected List<Tuple<L,R>> delegate()
      Specified by:
      delegate in class com.google.common.collect.ForwardingList<Tuple<L,R>>
    • add

      public void add(L left, R right)
    • append

      public TupleList<L,R> append(L left, R right)
      Adds a tuple to the list, then returns this TupleList instance. This method is similar to add(Object, Object) but can be used for method chaining.
    • getLeft

      public List<L> getLeft()
      Returns a list consisting of the left element of every tuple.
    • getRight

      public List<R> getRight()
      Returns a list consisting of the right element of every tuple.
    • forEach

      public void forEach(BiConsumer<L,R> callback)
    • inverse

      public TupleList<R,L> inverse()
      Returns a new TupleList 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

      public TupleList<L,R> concat(TupleList<L,R> other)
      Returns a new TupleList that will contain all tuples from this list, followed by all tuples from other. This method is different from ForwardingCollection.addAll(Collection) in that it does not modify the current list, and instead always creates and returns a new TupleList instance.
    • map

      public <L2, R2> TupleList<L2,R2> map(Function<L,L2> leftMapper, Function<R,R2> rightMapper)
    • immutable

      public TupleList<L,R> immutable()
      Creates a new TupleList that contains the same elements as this one, but does not allow modification. Attempting to modify the contents will result in an UnsupportedOperationException.
    • create

      public static <L, R> TupleList<L,R> create()
      Factory method that creates a TupleList that is mutable and initially empty.
    • of

      @SafeVarargs public static <L, R> TupleList<L,R> of(Tuple<L,R>... entries)
      Factory method that creates a mutable TupleList from existing tuples.
    • of

      @Deprecated public static <L, R> TupleList<L,R> of(List<Tuple<L,R>> entries)
      Deprecated.
      Renamed to copyOf(List), both because the new name is more descriptive and to be consistent with other collection classes.
      Factory method that creates a mutable TupleList from an existing list of tuples.
    • copyOf

      public static <L, R> TupleList<L,R> copyOf(List<Tuple<L,R>> entries)
      Factory method that creates a mutable TupleList from an existing list of tuples.
    • fromStream

      public static <L, R> TupleList<L,R> fromStream(Stream<Tuple<L,R>> tuples)
      Factory method that creates a mutable TupleList from an existing stream of tuples.
    • fromMap

      public static <L, R> TupleList<L,R> fromMap(Map<L,R> values)
      Factory method that creates a mutable TupleList 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

      public static <L, R> TupleList<L,R> combine(List<L> leftEntries, List<R> rightEntries)
      Creates a TupleList 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

      public static <L, R> TupleList<L,R> empty()
      Creates a new TupleList that is initially empty, and will throw an UnsupportedOperationException when trying to modify it.