Class ImmutableList.ReverseImmutableList<E>

All Implemented Interfaces:
Serializable, Iterable<E>, Collection<E>, List<E>, RandomAccess, SequencedCollection<E>
Enclosing class:
ImmutableList<E>

private static class ImmutableList.ReverseImmutableList<E> extends ImmutableList<E>
  • Field Details

  • Constructor Details

    • ReverseImmutableList

      ReverseImmutableList(ImmutableList<E> backingList)
  • Method Details

    • reverseIndex

      private int reverseIndex(int index)
    • reversePosition

      private int reversePosition(int index)
    • reverse

      public ImmutableList<E> reverse()
      Description copied from class: ImmutableList
      Returns a view of this immutable list in reverse order. For example, ImmutableList.of(1, 2, 3).reverse() is equivalent to ImmutableList.of(3, 2, 1).
      Overrides:
      reverse in class ImmutableList<E>
      Returns:
      a view of this immutable list in reverse order
    • contains

      public boolean contains(@CheckForNull Object object)
      Specified by:
      contains in interface Collection<E>
      Specified by:
      contains in interface List<E>
      Overrides:
      contains in class ImmutableList<E>
    • indexOf

      public int indexOf(@CheckForNull Object object)
      Specified by:
      indexOf in interface List<E>
      Overrides:
      indexOf in class ImmutableList<E>
    • lastIndexOf

      public int lastIndexOf(@CheckForNull Object object)
      Specified by:
      lastIndexOf in interface List<E>
      Overrides:
      lastIndexOf in class ImmutableList<E>
    • subList

      public ImmutableList<E> subList(int fromIndex, int toIndex)
      Description copied from class: ImmutableList
      Returns an immutable list of the elements between the specified fromIndex, inclusive, and toIndex, exclusive. (If fromIndex and toIndex are equal, the empty immutable list is returned.)

      Note: in almost all circumstances, the returned ImmutableList retains a strong reference to this, which may prevent the original list from being garbage collected. If you want the original list to be eligible for garbage collection, you should create and use a copy of the sub list (e.g., ImmutableList.copyOf(originalList.subList(...))).

      Specified by:
      subList in interface List<E>
      Overrides:
      subList in class ImmutableList<E>
    • get

      public E get(int index)
    • 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>
    • isPartialView

      boolean isPartialView()
      Description copied from class: ImmutableCollection
      Returns true if this immutable collection's implementation contains references to user-created objects that aren't accessible via this collection's methods. This is generally used to determine whether copyOf implementations should make an explicit copy to avoid memory leaks.
      Specified by:
      isPartialView in class ImmutableCollection<E>
    • writeReplace

      Object writeReplace()
      Overrides:
      writeReplace in class ImmutableList<E>