Interface PairList<T,U>

Type Parameters:
T - First type
U - Second type
All Superinterfaces:
Collection<Map.Entry<T,U>>, Iterable<Map.Entry<T,U>>, List<Map.Entry<T,U>>
All Known Subinterfaces:
ImmutablePairList<T,U>

public interface PairList<T,U> extends List<Map.Entry<T,U>>
A list of pairs, stored as a quotient list.
  • Method Details

    • of

      static <T, U> PairList<T,U> of()
      Creates an empty PairList.
    • of

      static <T, U> PairList<T,U> of(T t, U u)
      Creates a singleton PairList.
    • copyOf

      static <T, U> PairList<T,U> copyOf(T t, U u, Object... rest)
      Creates a PairList with one or more entries.
    • withCapacity

      static <T, U> PairList<T,U> withCapacity(int initialCapacity)
      Creates an empty PairList with a specified initial capacity.
    • backedBy

      static <T, U> PairList<T,U> backedBy(List<@Nullable Object> list)
      Creates a PairList backed by a given list.

      Changes to the backing list will be reflected in the PairList. If the backing list is immutable, this PairList will be also.

    • of

      static <T, U> PairList<T,U> of(Map<T,U> map)
      Creates a PairList from a Map.
    • builder

      static <T, U> PairList.Builder<T,U> builder()
      Creates a Builder.
    • add

      default void add(T t, U u)
      Adds a pair to this list.
    • add

      default void add(int index, T t, U u)
      Adds a pair to this list at a given position.
    • addAll

      default boolean addAll(PairList<T,U> list2)
      Adds to this list the contents of another PairList.

      Equivalent to List.addAll(Collection), but more efficient.

    • addAll

      default boolean addAll(int index, PairList<T,U> list2)
      Adds to this list, at a given index, the contents of another PairList.

      Equivalent to List.addAll(int, Collection), but more efficient.

    • set

      default Map.Entry<T,U> set(int index, T t, U u)
      Sets the entry at position index to the pair (t, u).
    • remove

      default Map.Entry<T,U> remove(int index)
      Specified by:
      remove in interface List<T>
    • left

      T left(int index)
      Returns the left part of the indexth pair.
    • right

      U right(int index)
      Returns the right part of the indexth pair.
    • leftList

      List<T> leftList()
      Returns an unmodifiable list view consisting of the left entry of each pair.
    • rightList

      List<U> rightList()
      Returns an unmodifiable list view consisting of the right entry of each pair.
    • forEach

      void forEach(BiConsumer<T,U> consumer)
      Calls a BiConsumer with each pair in this list.
    • forEachIndexed

      void forEachIndexed(PairList.IndexedBiConsumer<T,U> consumer)
      Calls a BiConsumer with each pair in this list.
    • toImmutableMap

      default com.google.common.collect.ImmutableMap<T,U> toImmutableMap()
      Creates an ImmutableMap whose entries are the pairs in this list. Throws if keys are not unique.
    • immutable

      ImmutablePairList<T,U> immutable()
      Returns an ImmutablePairList whose contents are the same as this PairList.
    • transform

      <R> List<R> transform(BiFunction<T,U,R> function)
      Applies a mapping function to each element of this list.
    • transform2

      <R> com.google.common.collect.ImmutableList<R> transform2(BiFunction<T,U,R> function)
      Applies a mapping function to each element of this list.
    • subList

      PairList<T,U> subList(int fromIndex, int toIndex)
      Specified by:
      subList in interface List<T>
    • anyMatch

      boolean anyMatch(BiPredicate<T,U> predicate)
      Returns whether the predicate is true for at least one pair in this list.
    • allMatch

      boolean allMatch(BiPredicate<T,U> predicate)
      Returns whether the predicate is true for all pairs in this list.
    • noMatch

      boolean noMatch(BiPredicate<T,U> predicate)
      Returns whether the predicate is true for no pairs in this list.
    • reverse

      default void reverse()
      Reverses the contents of this PairList. Throws if this PairList is immutable.
      See Also:
    • reversed

      ImmutablePairList<T,U> reversed()
      Returns an immutable copy of this ImmutablePairList with the elements reversed.

      Throws NullPointerException if any keys or values are null.