Interface UnmodList<E>

    • Method Detail

      • permutations

        static <T> void permutations​(List<T> items,
                                     Fn2<? super T,​? super T,​?> f)
        Apply the given function against all unique pairings of items in the list. Does this belong on Fn2 instead of List?
      • add

        @Deprecated
        default void add​(int index,
                         E element)
        Deprecated.
        Not allowed - this is supposed to be unmodifiable
        Specified by:
        add in interface List<E>
      • addAll

        @Deprecated
        default boolean addAll​(int index,
                               @NotNull
                               @NotNull Collection<? extends E> c)
        Deprecated.
        Not allowed - this is supposed to be unmodifiable
        Specified by:
        addAll in interface List<E>
      • contains

        @Deprecated
        default boolean contains​(Object o)
        Deprecated.
        This method is deprecated because implementing it on a List has O(n) performance. It will never go away because it's declared on java.util.Collection which List extends. It still shouldn't be used. If you need repeated or fast contains() tests, use a Set instead instead of a List. SortedSet.contains() has O(log2 n) performance. HashSet.contains() has O(1) performance! If you truly need a one-shot contains test, iterate the list manually, or override the deprecation warning, but include a description of why you need to use a List instead of some kind of Set or Map!
        Specified by:
        contains in interface Collection<E>
        Specified by:
        contains in interface List<E>
      • containsAll

        default boolean containsAll​(@NotNull
                                    @NotNull Collection<?> c)
        The default implementation of this method has O(this.size() + that.size()) or O(n) performance. So even though contains() is impossible to implement efficiently for Lists, containsAll() has a decent implementation (brute force would be O(this.size() * that.size()) or O(n^2) ).
        Specified by:
        containsAll in interface Collection<E>
        Specified by:
        containsAll in interface List<E>
        Specified by:
        containsAll in interface UnmodCollection<E>
      • indexOf

        default int indexOf​(Object o)
        The default implementation of this method has O(this.size()) performance. If you call this much, you probably want to use a Map<Integer,T> instead for O(1) performance.
        Specified by:
        indexOf in interface List<E>
      • lastIndexOf

        default int lastIndexOf​(Object o)
        The default implementation of this method has O(this.size()) performance.
        Specified by:
        lastIndexOf in interface List<E>
      • listIterator

        @NotNull
        default @NotNull UnmodListIterator<E> listIterator​(int index)
        Subclasses should override this when they can do so more efficiently.
        Specified by:
        listIterator in interface List<E>
      • remove

        @Deprecated
        default E remove​(int index)
        Deprecated.
        Not allowed - this is supposed to be unmodifiable
        Specified by:
        remove in interface List<E>
      • set

        @Deprecated
        default E set​(int index,
                      E element)
        Deprecated.
        Not allowed - this is supposed to be unmodifiable
        Specified by:
        set in interface List<E>
      • sort

        @Deprecated
        default void sort​(Comparator<? super E> c)
        Deprecated.
        Not allowed - this is supposed to be unmodifiable
        Specified by:
        sort in interface List<E>
      • subList

        @NotNull
        default @NotNull UnmodList<E> subList​(int fromIndex,
                                              int toIndex)
        Specified by:
        subList in interface List<E>
      • toArray

        default Object @NotNull [] toArray()
        This method goes against Josh Bloch's Item 25: "Prefer Lists to Arrays", but is provided for backwards compatibility in some performance-critical situations. If you really need an array, consider using the somewhat type-safe version of this method instead, but read the caveats first. This method goes against Josh Bloch's Item 25: "Prefer Lists to Arrays", but is provided for backwards compatibility in some performance-critical situations. If you really need an array, consider using the somewhat type-safe version of this method instead, but read the caveats first.
        Specified by:
        toArray in interface Collection<E>
        Specified by:
        toArray in interface List<E>
        Specified by:
        toArray in interface UnmodCollection<E>
      • toArray

        default <T> T @NotNull [] toArray​(T @NotNull [] as)
        This method goes against Josh Bloch's Item 25: "Prefer Lists to Arrays", but is provided for backwards compatibility in some performance-critical situations. If you need to create an array (you almost always do) then the best way to use this method is: MyThing[] things = col.toArray(new MyThing[coll.size()]); Calling this method any other way causes unnecessary work to be done - an extra memory allocation and potential garbage collection if the passed array is too small, extra effort to fill the end of the array with nulls if it is too large. This method goes against Josh Bloch's Item 25: "Prefer Lists to Arrays", but is provided for backwards compatibility in some performance-critical situations. If you need to create an array (you almost always do) then the best way to use this method is: MyThing[] things = col.toArray(new MyThing[coll.size()]); Calling this method any other way causes unnecessary work to be done - an extra memory allocation and potential garbage collection if the passed array is too small, extra effort to fill the end of the array with nulls if it is too large.
        Specified by:
        toArray in interface Collection<E>
        Specified by:
        toArray in interface List<E>
        Specified by:
        toArray in interface UnmodCollection<E>