Class IngredientList<T,M>

Type Parameters:
T - The instance type.
M - The matching condition parameter.
All Implemented Interfaces:
Iterable<T>, IIngredientCollection<T,M>, IIngredientCollectionLike<T,M,T>, IIngredientCollectionMutable<T,M>, IIngredientList<T,M>, IIngredientListMutable<T,M>
Direct Known Subclasses:
IngredientArrayList, IngredientLinkedList

public class IngredientList<T,M> extends IngredientCollectionCollectionAdapter<T,M,List<T>> implements IIngredientListMutable<T,M>
A mutable 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:
  • Constructor Details

  • Method Details

    • equals

      public boolean equals(Object obj)
      Description copied from interface: IIngredientCollectionLike
      Check if this collection equals the given object.
      Specified by:
      equals in interface IIngredientCollectionLike<T,M,T>
      Overrides:
      equals in class Object
      Parameters:
      obj - An object.
      Returns:
      True if the given object is an ingredient collection of the same type, component type and contains the same instances.
    • get

      @Nullable public T get(int index)
      Description copied from interface: IIngredientList
      Get the instance at the given index.
      Specified by:
      get in interface IIngredientList<T,M>
      Parameters:
      index - An index.
      Returns:
      The instance at the given index.
    • set

      @Nullable public T set(int index, T instance)
      Description copied from interface: IIngredientList
      Set the instance at the given index.
      Specified by:
      set in interface IIngredientList<T,M>
      Parameters:
      index - An index.
      instance - The instance to set.
      Returns:
      The previous instance at the given position.
    • add

      public void add(int index, T instance)
      Description copied from interface: IIngredientList
      Insert the given instance at the given position and shift all instances after it (if any) to the right (add one to their index).
      Specified by:
      add in interface IIngredientList<T,M>
      Parameters:
      index - An index.
      instance - The instances to add.
    • remove

      @Nullable public T remove(int index)
      Description copied from interface: IIngredientList
      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).
      Specified by:
      remove in interface IIngredientList<T,M>
      Parameters:
      index - An index.
      Returns:
      The removed index if one existed.
    • firstIndexOf

      public int firstIndexOf(T instance)
      Description copied from interface: IIngredientList
      The first index that has an instance that equals the given instance.
      Specified by:
      firstIndexOf in interface IIngredientList<T,M>
      Parameters:
      instance - An instance.
      Returns:
      The first matching instance's index, or -1 if none.
    • lastIndexOf

      public int lastIndexOf(T instance)
      Description copied from interface: IIngredientList
      The last index that has an instance that equals the given instance.
      Specified by:
      lastIndexOf in interface IIngredientList<T,M>
      Parameters:
      instance - An instance.
      Returns:
      The last matching instance's index, or -1 if none.
    • listIterator

      public ListIterator<T> listIterator()
      Specified by:
      listIterator in interface IIngredientList<T,M>
      Returns:
      A list iterator over all instances.
    • listIterator

      public ListIterator<T> listIterator(int offset)
      Description copied from interface: IIngredientList
      Get the offsetted list index.
      Specified by:
      listIterator in interface IIngredientList<T,M>
      Parameters:
      offset - An index to start iterating from.
      Returns:
      A list iterator that is offsetted by `offset` instances.
    • subList

      public IIngredientList<T,M> subList(int fromIndex, int toIndex)
      Description copied from interface: IIngredientList
      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.
      Specified by:
      subList in interface IIngredientList<T,M>
      Parameters:
      fromIndex - The starting index (inclusive).
      toIndex - The ending index (exclusive).
      Returns:
      The sublist view.