Class MutableList<T>

All Implemented Interfaces:
Cloneable, Iterable<T>, MutableCollection<T>, Traversable<T>

public abstract class MutableList<T> extends List<T> implements MutableCollection<T>
List that can be mutated.
  • Method Details

    • empty

      public static <T> MutableList<T> empty()
      New mutable list that is initially empty.
    • of

      @SafeVarargs public static <T> MutableList<T> of(T... elements)
      New mutable list that initially contains given elements.
    • of

      public static <T> MutableList<T> of(Collection<? extends T> elements)
      New mutable list that initially contains given elements.
    • set

      public abstract T set(int elementIndex, T element)
      Assigns new element to the given index.
      Throws:
      IndexOutOfBoundsException - if index < 0 or index >= size()
    • insert

      public abstract void insert(int insertIndex, T element)
      Inserts element at the specified index of the list.
      Throws:
      IndexOutOfBoundsException - if index < 0 or index > size()
    • insertAll

      public void insertAll(int insertIndex, Collection<? extends T> elements)
      Inserts elements at the specified position of the list. Elements are inserted in the order returned by collection iterator.
    • add

      public boolean add(T element)
      Adds new element to the end of this list.
      Specified by:
      add in interface MutableCollection<T>
      Returns:
      true because list always changes after this operation.
    • addAll

      public boolean addAll(Collection<? extends T> elements)
      Adds all elements from given collection to the end of this list.
      Specified by:
      addAll in interface MutableCollection<T>
      Returns:
      true if the supplied collection is non-empty.
    • removeAt

      public abstract T removeAt(int elementIndex)
      Removes element at given index.
    • removeRange

      public abstract void removeRange(int from, int to)
      Removes all elements in given range of this list.
    • sortBy

      public abstract void sortBy(Comparator<? super T> comparing)
      Sorts this list using given comparator.
    • transform

      public void transform(UnaryOperator<T> transformation)
      Transforms elements of this list using given transformation.
      Since:
      3.1
    • indexedTransform

      public void indexedTransform(BiFunction<Integer,T,T> transformation)
      Transforms elements of this list using given transformation.
      Since:
      3.1