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
ConstructorsConstructorDescriptionIngredientCollectionSingleClassified(IngredientComponent<T, M> component, Supplier<L> collectionCreator, IngredientComponentCategoryType<T, M, C> categoryType) Create a new instance. -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdd the given instance to the collection.voidclear()Clears this collection of all instances.booleanCheck if this collection contains the given instance.booleanCheck if this collection contains the given instance under the given match conditions.intCount the number of occurrences of the given instance under the given match conditions.booleanCheck 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.booleanRemove the given instance from the collection.intRemove all occurrences of the given instance under the given match conditions.voidsetSize(int size) Set the internal size value.intsize()Methods inherited from class org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionAdapter
getComponent, hashCode, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientCollection
containsAll, containsAll, parallelStream, spliterator, stream, toArrayMethods inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionLike
getComponent, hashCode, isEmpty, toStringMethods inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionLikeSingleClassifiedTrait
appliesToClassifier, getClassifier, getOrCreateClassifiedCollectionMethods 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:
getCategoryTypein interfaceIIngredientCollectionLikeSingleClassifiedTrait<T,M, T, C, L extends IIngredientCollectionMutable<T, M>> - Returns:
- The category type using which this collection classifies.
-
createEmptyCollection
- Specified by:
createEmptyCollectionin interfaceIIngredientCollectionLikeSingleClassifiedTrait<T,M, T, C, L extends IIngredientCollectionMutable<T, M>> - Returns:
- A new collection-like for internal classification usage.
-
getInstance
Description copied from interface:IIngredientCollectionLikeSingleClassifiedTraitGet the instance from the given iterator instance. This is used internally for iteration purposes. This typically is just a no-op.- Specified by:
getInstancein interfaceIIngredientCollectionLikeSingleClassifiedTrait<T,M, T, C, L extends IIngredientCollectionMutable<T, M>> - Parameters:
iterableInstance- An iterator instance.- Returns:
- An instance.
-
getClassifiedCollections
- Specified by:
getClassifiedCollectionsin 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:IIngredientCollectionLikeSingleClassifiedTraitSet the internal size value. This should not be called outside of internal usage, such as custom iterators that can mutate this collection.- Specified by:
setSizein interfaceIIngredientCollectionLikeSingleClassifiedTrait<T,M, T, C, L extends IIngredientCollectionMutable<T, M>> - Parameters:
size- The new size.
-
size
public int size()- Specified by:
sizein interfaceIIngredientCollectionLike<T,M, C> - Returns:
- The number of instances contained in this collection.
-
add
Description copied from interface:IIngredientCollectionMutableAdd the given instance to the collection.- Specified by:
addin 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:IIngredientCollectionMutableRemove the given instance from the collection.- Specified by:
removein interfaceIIngredientCollectionMutable<T,M> - Overrides:
removein 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:IIngredientCollectionMutableRemove 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:
removeAllin interfaceIIngredientCollectionMutable<T,M> - Overrides:
removeAllin classIngredientCollectionAdapter<T,M> - Parameters:
instance- An instance.matchCondition- A match condition.- Returns:
- The number of removed instances.
-
contains
Description copied from interface:IIngredientCollectionCheck if this collection contains the given instance. This instance will be compared based on the matcher from the ingredient component type.- Specified by:
containsin interfaceIIngredientCollection<T,M> - Overrides:
containsin classIngredientCollectionAdapter<T,M> - Parameters:
instance- An instance.- Returns:
- If this collection contains the given instance.
-
contains
Description copied from interface:IIngredientCollectionCheck 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:
containsin interfaceIIngredientCollection<T,M> - Overrides:
containsin 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:IIngredientCollectionMutableClears this collection of all instances.- Specified by:
clearin interfaceIIngredientCollectionMutable<T,M>
-
count
Description copied from interface:IIngredientCollectionCount 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:
countin interfaceIIngredientCollection<T,M> - Overrides:
countin 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:IIngredientCollectionLikeCheck if this collection equals the given object. -
iterator
-
iterator
Description copied from interface:IIngredientCollectionAn iterator over this collection over all occurrences of the given instance under the given match conditions.- Specified by:
iteratorin interfaceIIngredientCollection<T,M> - Specified by:
iteratorin interfaceIIngredientCollectionLike<T,M, C> - Overrides:
iteratorin 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.
-