Class ImmutableList<E>

  • All Implemented Interfaces:
    java.lang.Iterable<E>, java.util.Collection<E>, java.util.List<E>, java.util.RandomAccess

    final class ImmutableList<E>
    extends java.util.AbstractList<E>
    implements java.util.List<E>, java.util.RandomAccess
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) E[] elements  
      (package private) static ImmutableList<?> EMPTY  
      • Fields inherited from class java.util.AbstractList

        modCount
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      (package private) ImmutableList​(E... elements)  
      private ImmutableList​(E[] elements, int fromIndex, int toIndex)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(int i, E e)  
      boolean add​(E e)  
      boolean addAll​(int index, java.util.Collection<? extends E> collection)  
      boolean addAll​(java.util.Collection<? extends E> collection)  
      void clear()  
      boolean contains​(java.lang.Object o)  
      boolean equals​(java.lang.Object o)  
      E get​(int index)  
      int hashCode()  
      int indexOf​(java.lang.Object o)  
      java.util.Iterator<E> iterator()  
      int lastIndexOf​(java.lang.Object o)  
      java.util.ListIterator<E> listIterator()  
      java.util.ListIterator<E> listIterator​(int index)  
      boolean remove​(java.lang.Object o)  
      boolean removeAll​(java.util.Collection<?> collection)  
      boolean removeIf​(java.util.function.Predicate<? super E> filter)  
      void replaceAll​(java.util.function.UnaryOperator<E> operator)  
      boolean retainAll​(java.util.Collection<?> collection)  
      E set​(int i, E e)  
      int size()  
      void sort​(java.util.Comparator<? super E> comparator)  
      java.util.List<E> subList​(int fromIndex, int toIndex)  
      java.lang.Object[] toArray()  
      <T> T[] toArray​(T[] array)  
      • Methods inherited from class java.util.AbstractList

        remove, removeRange
      • Methods inherited from class java.util.AbstractCollection

        containsAll, isEmpty, toString
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, stream, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.List

        containsAll, isEmpty, remove, spliterator
    • Field Detail

      • elements

        final E[] elements
    • Constructor Detail

      • ImmutableList

        @SafeVarargs
        ImmutableList​(E... elements)
      • ImmutableList

        private ImmutableList​(E[] elements,
                              int fromIndex,
                              int toIndex)
    • Method Detail

      • iterator

        public java.util.Iterator<E> iterator()
        Specified by:
        iterator in interface java.util.Collection<E>
        Specified by:
        iterator in interface java.lang.Iterable<E>
        Specified by:
        iterator in interface java.util.List<E>
        Overrides:
        iterator in class java.util.AbstractList<E>
      • listIterator

        public java.util.ListIterator<E> listIterator()
        Specified by:
        listIterator in interface java.util.List<E>
        Overrides:
        listIterator in class java.util.AbstractList<E>
      • listIterator

        public java.util.ListIterator<E> listIterator​(int index)
        Specified by:
        listIterator in interface java.util.List<E>
        Overrides:
        listIterator in class java.util.AbstractList<E>
      • 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>
      • get

        public E get​(int index)
        Specified by:
        get in interface java.util.List<E>
        Specified by:
        get in class java.util.AbstractList<E>
      • subList

        public java.util.List<E> subList​(int fromIndex,
                                         int toIndex)
        Specified by:
        subList in interface java.util.List<E>
        Overrides:
        subList in class java.util.AbstractList<E>
      • contains

        public boolean contains​(java.lang.Object o)
        Specified by:
        contains in interface java.util.Collection<E>
        Specified by:
        contains in interface java.util.List<E>
        Overrides:
        contains in class java.util.AbstractCollection<E>
      • indexOf

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

        public int lastIndexOf​(java.lang.Object o)
        Specified by:
        lastIndexOf in interface java.util.List<E>
        Overrides:
        lastIndexOf in class java.util.AbstractList<E>
      • toArray

        public java.lang.Object[] toArray()
        Specified by:
        toArray in interface java.util.Collection<E>
        Specified by:
        toArray in interface java.util.List<E>
        Overrides:
        toArray in class java.util.AbstractCollection<E>
      • toArray

        public <T> T[] toArray​(T[] array)
        Specified by:
        toArray in interface java.util.Collection<E>
        Specified by:
        toArray in interface java.util.List<E>
        Overrides:
        toArray in class java.util.AbstractCollection<E>
      • equals

        public boolean equals​(java.lang.Object o)
        Specified by:
        equals in interface java.util.Collection<E>
        Specified by:
        equals in interface java.util.List<E>
        Overrides:
        equals in class java.util.AbstractList<E>
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Collection<E>
        Specified by:
        hashCode in interface java.util.List<E>
        Overrides:
        hashCode in class java.util.AbstractList<E>
      • add

        public boolean add​(E e)
        Specified by:
        add in interface java.util.Collection<E>
        Specified by:
        add in interface java.util.List<E>
        Overrides:
        add in class java.util.AbstractList<E>
      • add

        public void add​(int i,
                        E e)
        Specified by:
        add in interface java.util.List<E>
        Overrides:
        add in class java.util.AbstractList<E>
      • set

        public E set​(int i,
                     E e)
        Specified by:
        set in interface java.util.List<E>
        Overrides:
        set in class java.util.AbstractList<E>
      • remove

        public boolean remove​(java.lang.Object o)
        Specified by:
        remove in interface java.util.Collection<E>
        Specified by:
        remove in interface java.util.List<E>
        Overrides:
        remove in class java.util.AbstractCollection<E>
      • addAll

        public boolean addAll​(java.util.Collection<? extends E> collection)
        Specified by:
        addAll in interface java.util.Collection<E>
        Specified by:
        addAll in interface java.util.List<E>
        Overrides:
        addAll in class java.util.AbstractCollection<E>
      • addAll

        public boolean addAll​(int index,
                              java.util.Collection<? extends E> collection)
        Specified by:
        addAll in interface java.util.List<E>
        Overrides:
        addAll in class java.util.AbstractList<E>
      • removeAll

        public boolean removeAll​(java.util.Collection<?> collection)
        Specified by:
        removeAll in interface java.util.Collection<E>
        Specified by:
        removeAll in interface java.util.List<E>
        Overrides:
        removeAll in class java.util.AbstractCollection<E>
      • retainAll

        public boolean retainAll​(java.util.Collection<?> collection)
        Specified by:
        retainAll in interface java.util.Collection<E>
        Specified by:
        retainAll in interface java.util.List<E>
        Overrides:
        retainAll in class java.util.AbstractCollection<E>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<E>
        Specified by:
        clear in interface java.util.List<E>
        Overrides:
        clear in class java.util.AbstractList<E>
      • removeIf

        public boolean removeIf​(java.util.function.Predicate<? super E> filter)
        Specified by:
        removeIf in interface java.util.Collection<E>
      • replaceAll

        public void replaceAll​(java.util.function.UnaryOperator<E> operator)
        Specified by:
        replaceAll in interface java.util.List<E>
      • sort

        public void sort​(java.util.Comparator<? super E> comparator)
        Specified by:
        sort in interface java.util.List<E>