Class IngredientCollectionSingleClassified<T,M,C,L extends IIngredientCollectionMutable<T,M>>
java.lang.Object
org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionAdapter<T,M>
org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionSingleClassified<T,M,C,L>
- Type Parameters:
T
- An instance type.M
- The matching condition parameter.C
- A classifier type.L
- The inner collection type.
- All Implemented Interfaces:
Iterable<T>
,IIngredientCollection<T,
,M> IIngredientCollectionLike<T,
,M, T> IIngredientCollectionLikeSingleClassifiedTrait<T,
,M, T, C, L> IIngredientCollectionMutable<T,
M>
- Direct Known Subclasses:
IngredientCollectionSingleClassifiedCollapsed
public class IngredientCollectionSingleClassified<T,M,C,L extends IIngredientCollectionMutable<T,M>>
extends IngredientCollectionAdapter<T,M>
implements IIngredientCollectionLikeSingleClassifiedTrait<T,M,T,C,L>
An ingredient collection that classifies instances in smaller collections based on a category type.
This allows instances to be looked up or removed more efficiently when the used match condition
is compatible with the identifying match condition of the configured category type.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionLikeSingleClassifiedTrait
IIngredientCollectionLikeSingleClassifiedTrait.ClassifiedIterator<T,
M, I, C, L extends IIngredientCollectionLike<T, M, I>>, IIngredientCollectionLikeSingleClassifiedTrait.ClassifiedIteratorDelegated<T, M, C, I, L extends IIngredientCollectionLike<T, M, I>> -
Constructor Summary
ConstructorDescriptionIngredientCollectionSingleClassified
(IngredientComponent<T, M> component, Supplier<L> collectionCreator, IngredientComponentCategoryType<T, M, C> categoryType) Create a new instance. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Add the given instance to the collection.void
clear()
Clears this collection of all instances.boolean
Check if this collection contains the given instance.boolean
Check if this collection contains the given instance under the given match conditions.int
Count the number of occurrences of the given instance under the given match conditions.boolean
Check if this collection equals the given object.getInstance
(T iterableInstance) Get the instance from the given iterator instance.iterator()
An iterator over this collection over all occurrences of the given instance under the given match conditions.boolean
Remove the given instance from the collection.int
Remove all occurrences of the given instance under the given match conditions.void
setSize
(int size) Set the internal size value.int
size()
Methods inherited from class org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionAdapter
getComponent, hashCode, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientCollection
containsAll, containsAll, parallelStream, spliterator, stream, toArray
Methods inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionLike
getComponent, hashCode, isEmpty, toString
Methods inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionLikeSingleClassifiedTrait
appliesToClassifier, getClassifier, getOrCreateClassifiedCollection
Methods inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionMutable
addAll, removeAll, removeAll
-
Constructor Details
-
IngredientCollectionSingleClassified
public IngredientCollectionSingleClassified(IngredientComponent<T, M> component, Supplier<L> collectionCreator, IngredientComponentCategoryType<T, M, C> categoryType) Create a new instance.- Parameters:
component
- A component type.collectionCreator
- A callback for creating new internal collections for a single classifier.categoryType
- A category type using which this collection will classify instance.
-
-
Method Details
-
getCategoryType
- Specified by:
getCategoryType
in interfaceIIngredientCollectionLikeSingleClassifiedTrait<T,
M, T, C, L extends IIngredientCollectionMutable<T, M>> - Returns:
- The category type using which this collection classifies.
-
createEmptyCollection
- Specified by:
createEmptyCollection
in interfaceIIngredientCollectionLikeSingleClassifiedTrait<T,
M, T, C, L extends IIngredientCollectionMutable<T, M>> - Returns:
- A new collection-like for internal classification usage.
-
getInstance
Description copied from interface:IIngredientCollectionLikeSingleClassifiedTrait
Get the instance from the given iterator instance. This is used internally for iteration purposes. This typically is just a no-op.- Specified by:
getInstance
in interfaceIIngredientCollectionLikeSingleClassifiedTrait<T,
M, T, C, L extends IIngredientCollectionMutable<T, M>> - Parameters:
iterableInstance
- An iterator instance.- Returns:
- An instance.
-
getClassifiedCollections
- Specified by:
getClassifiedCollections
in interfaceIIngredientCollectionLikeSingleClassifiedTrait<T,
M, T, C, L extends IIngredientCollectionMutable<T, M>> - Returns:
- A mapping of all internal classified collections.
-
setSize
public void setSize(int size) Description copied from interface:IIngredientCollectionLikeSingleClassifiedTrait
Set the internal size value. This should not be called outside of internal usage, such as custom iterators that can mutate this collection.- Specified by:
setSize
in interfaceIIngredientCollectionLikeSingleClassifiedTrait<T,
M, T, C, L extends IIngredientCollectionMutable<T, M>> - Parameters:
size
- The new size.
-
size
public int size()- Specified by:
size
in interfaceIIngredientCollectionLike<T,
M, C> - Returns:
- The number of instances contained in this collection.
-
add
Description copied from interface:IIngredientCollectionMutable
Add the given instance to the collection.- Specified by:
add
in interfaceIIngredientCollectionMutable<T,
M> - Parameters:
instance
- An instance.- Returns:
- If the collection was changed due to this addition. This can be false in the case of sets in which each instance can only exists once.
-
remove
Description copied from interface:IIngredientCollectionMutable
Remove the given instance from the collection.- Specified by:
remove
in interfaceIIngredientCollectionMutable<T,
M> - Overrides:
remove
in classIngredientCollectionAdapter<T,
M> - Parameters:
instance
- An instance.- Returns:
- If the collection was changed due to this addition. Can be false if the collection did not contain the instance.
-
removeAll
Description copied from interface:IIngredientCollectionMutable
Remove all occurrences of the given instance under the given match conditions. This instance will be compared based on the matcher from the ingredient component type using the given match condition.- Specified by:
removeAll
in interfaceIIngredientCollectionMutable<T,
M> - Overrides:
removeAll
in classIngredientCollectionAdapter<T,
M> - Parameters:
instance
- An instance.matchCondition
- A match condition.- Returns:
- The number of removed instances.
-
contains
Description copied from interface:IIngredientCollection
Check if this collection contains the given instance. This instance will be compared based on the matcher from the ingredient component type.- Specified by:
contains
in interfaceIIngredientCollection<T,
M> - Overrides:
contains
in classIngredientCollectionAdapter<T,
M> - Parameters:
instance
- An instance.- Returns:
- If this collection contains the given instance.
-
contains
Description copied from interface:IIngredientCollection
Check if this collection contains the given instance under the given match conditions. This instance will be compared based on the matcher from the ingredient component type using the given match condition.- Specified by:
contains
in interfaceIIngredientCollection<T,
M> - Overrides:
contains
in classIngredientCollectionAdapter<T,
M> - Parameters:
instance
- An instance.matchCondition
- A match condition.- Returns:
- If this collection contains the given instance under the given match conditions.
-
clear
public void clear()Description copied from interface:IIngredientCollectionMutable
Clears this collection of all instances.- Specified by:
clear
in interfaceIIngredientCollectionMutable<T,
M>
-
count
Description copied from interface:IIngredientCollection
Count the number of occurrences of the given instance under the given match conditions. This instance will be compared based on the matcher from the ingredient component type using the given match condition.- Specified by:
count
in interfaceIIngredientCollection<T,
M> - Overrides:
count
in classIngredientCollectionAdapter<T,
M> - Parameters:
instance
- An instance.matchCondition
- A match condition.- Returns:
- The number of occurrences of the given instance under the given match conditions.
-
equals
Description copied from interface:IIngredientCollectionLike
Check if this collection equals the given object. -
iterator
-
iterator
Description copied from interface:IIngredientCollection
An iterator over this collection over all occurrences of the given instance under the given match conditions.- Specified by:
iterator
in interfaceIIngredientCollection<T,
M> - Specified by:
iterator
in interfaceIIngredientCollectionLike<T,
M, C> - Overrides:
iterator
in classIngredientCollectionAdapter<T,
M> - Parameters:
instance
- An instance.matchCondition
- A match condition.- Returns:
- An iterator over this collection over all occurrences of the given instance under the given match conditions.
-