Interface IIngredientList<T,M>

Type Parameters:
T - The instance type.
M - The matching condition parameter.
All Superinterfaces:
IIngredientCollection<T,M>, IIngredientCollectionLike<T,M,T>, Iterable<T>
All Known Subinterfaces:
IIngredientListMutable<T,M>
All Known Implementing Classes:
IngredientArrayList, IngredientLinkedList, IngredientList

public interface IIngredientList<T,M> extends IIngredientCollection<T,M>
An ingredient collection using list semantics. This means that instances exist in a predefined order and that instances can exist multiple time in the collection.
See Also:
  • Method Details

    • get

      @Nullable T get(int index)
      Get the instance at the given index.
      Parameters:
      index - An index.
      Returns:
      The instance at the given index.
      Throws:
      IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())
    • set

      @Nullable T set(int index, T instance)
      Set the instance at the given index.
      Parameters:
      index - An index.
      instance - The instance to set.
      Returns:
      The previous instance at the given position.
      Throws:
      IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())
    • add

      void add(int index, T instance)
      Insert the given instance at the given position and shift all instances after it (if any) to the right (add one to their index).
      Parameters:
      index - An index.
      instance - The instances to add.
      Throws:
      IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size())
    • remove

      @Nullable T remove(int index)
      Remove the instance at the given index. All following instances (with higher index; if any) will be shifted to the left (subtract one from their index).
      Parameters:
      index - An index.
      Returns:
      The removed index if one existed.
      Throws:
      IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())
    • firstIndexOf

      int firstIndexOf(T instance)
      The first index that has an instance that equals the given instance.
      Parameters:
      instance - An instance.
      Returns:
      The first matching instance's index, or -1 if none.
    • lastIndexOf

      int lastIndexOf(T instance)
      The last index that has an instance that equals the given instance.
      Parameters:
      instance - An instance.
      Returns:
      The last matching instance's index, or -1 if none.
    • listIterator

      ListIterator<T> listIterator()
      Returns:
      A list iterator over all instances.
    • listIterator

      ListIterator<T> listIterator(int offset)
      Get the offsetted list index.
      Parameters:
      offset - An index to start iterating from.
      Returns:
      A list iterator that is offsetted by `offset` instances.
      Throws:
      IndexOutOfBoundsException - for an illegal endpoint index value (fromIndex < 0 || toIndex > size || fromIndex > toIndex)
    • subList

      IIngredientList<T,M> subList(int fromIndex, int toIndex)
      Get a view of a sublist of the this list. As this is a view, any mutations on it will reflect on this list as well.
      Parameters:
      fromIndex - The starting index (inclusive).
      toIndex - The ending index (exclusive).
      Returns:
      The sublist view.
      Throws:
      IndexOutOfBoundsException - for an illegal endpoint index value (fromIndex < 0 || toIndex > size)
      IllegalArgumentException - if fromIndex > toIndex
    • sort

      default void sort(Comparator<? super T> comparator)
      Sort this list based on the given comparator.
      Parameters:
      comparator - A comparator.
    • spliterator

      default Spliterator<T> spliterator()
      Specified by:
      spliterator in interface IIngredientCollection<T,M>
      Specified by:
      spliterator in interface Iterable<T>