Class ImmutableList.ReverseImmutableList<E>

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.List<E>, java.util.RandomAccess
    Enclosing class:
    ImmutableList<E>

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

    • Constructor Detail

      • ReverseImmutableList

        ReverseImmutableList​(ImmutableList<E> backingList)
    • Method Detail

      • 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​(@Nullable
                                java.lang.Object object)
        Specified by:
        contains in interface java.util.Collection<E>
        Specified by:
        contains in interface java.util.List<E>
        Overrides:
        contains in class ImmutableList<E>
      • indexOf

        public int indexOf​(@Nullable
                           java.lang.Object object)
        Specified by:
        indexOf in interface java.util.List<E>
        Overrides:
        indexOf in class ImmutableList<E>
      • lastIndexOf

        public int lastIndexOf​(@Nullable
                               java.lang.Object object)
        Specified by:
        lastIndexOf in interface java.util.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.)
        Specified by:
        subList in interface java.util.List<E>
        Overrides:
        subList in class ImmutableList<E>
      • get

        public E get​(int index)
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<E>
        Specified by:
        size in interface java.util.List<E>
        Specified by:
        size in class java.util.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>