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
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 Summary
Modifier and TypeMethodDescriptionvoid
Insert the given instance at the given position and shift all instances after it (if any) to the right (add one to their index).int
firstIndexOf
(T instance) The first index that has an instance that equals the given instance.get
(int index) Get the instance at the given index.int
lastIndexOf
(T instance) The last index that has an instance that equals the given instance.listIterator
(int offset) Get the offsetted list index.remove
(int index) Remove the instance at the given index.Set the instance at the given index.default void
sort
(Comparator<? super T> comparator) Sort this list based on the given comparator.default Spliterator<T>
subList
(int fromIndex, int toIndex) Get a view of a sublist of the this list.Methods inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientCollection
contains, contains, containsAll, containsAll, count, iterator, parallelStream, stream, toArray
Methods inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionLike
equals, getComponent, hashCode, isEmpty, size, toString
-
Method Details
-
get
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
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
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
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
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
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
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
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
Sort this list based on the given comparator.- Parameters:
comparator
- A comparator.
-
spliterator
- Specified by:
spliterator
in interfaceIIngredientCollection<T,
M> - Specified by:
spliterator
in interfaceIterable<T>
-