Class IngredientCollectionMultiClassified<T,M>
java.lang.Object
org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionAdapter<T,M>
org.cyclops.cyclopscore.ingredient.collection.IngredientCollectionMultiClassified<T,M>
- Type Parameters:
T- An instance type.M- The matching condition parameter.
- All Implemented Interfaces:
Iterable<T>,IIngredientCollection<T,,M> IIngredientCollectionLike<T,,M, T> IIngredientCollectionLikeMultiClassifiedTrait<T,,M, T, IngredientCollectionSingleClassified<T, M, ?, ?>> IIngredientCollectionMutable<T,M>
public class IngredientCollectionMultiClassified<T,M>
extends IngredientCollectionAdapter<T,M>
implements IIngredientCollectionMutable<T,M>, IIngredientCollectionLikeMultiClassifiedTrait<T,M,T,IngredientCollectionSingleClassified<T,M,?,?>>
An ingredient collection that classifies instances in smaller collections
based on all category type of a component 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 category types.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionLikeMultiClassifiedTrait
IIngredientCollectionLikeMultiClassifiedTrait.RemoveCallbackIterator<T,M, I, L extends IIngredientCollectionLike<T, M, I>> -
Constructor Summary
ConstructorsConstructorDescriptionIngredientCollectionMultiClassified(IngredientComponent<T, M> component, Supplier<IIngredientCollectionMutable<T, M>> collectionCreator) -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdd the given instance to the collection.booleanaddAllThreaded(ExecutorService executorService, Iterable<? extends T> instances) A multi-threaded addAll implementation.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.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.voidremoveInstance(IngredientCollectionSingleClassified<T, M, ?, ?> collection, T iterableInstance) Remove the given instance from the given collection-like.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.IIngredientCollectionLikeMultiClassifiedTrait
getBestClassifiedCollection, getFirstMatchingCategory, getFirstSingleClassifiedMethods inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionMutable
addAll, removeAll, removeAll
-
Constructor Details
-
IngredientCollectionMultiClassified
public IngredientCollectionMultiClassified(IngredientComponent<T, M> component, Supplier<IIngredientCollectionMutable<T, M>> collectionCreator)
-
-
Method Details
-
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.
-
addAllThreaded
public boolean addAllThreaded(@Nullable ExecutorService executorService, Iterable<? extends T> instances) A multi-threaded addAll implementation. This will create workers for adding the given instances to all classified collections.- Parameters:
executorService- An optional executor service. If none is provided, a new temporary one will be created for the duration of this method call.instances- The instances that need to be added.- 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.
-
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.
-
clear
public void clear()Description copied from interface:IIngredientCollectionMutableClears this collection of all instances.- Specified by:
clearin interfaceIIngredientCollectionMutable<T,M>
-
size
public int size()- Specified by:
sizein interfaceIIngredientCollectionLike<T,M, T> - Returns:
- The number of instances contained in this collection.
-
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, T> - 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.
-
removeInstance
public void removeInstance(IngredientCollectionSingleClassified<T, M, ?, ?> collection, T iterableInstance) Description copied from interface:IIngredientCollectionLikeMultiClassifiedTraitRemove the given instance from the given collection-like. This is used internally for iteration purposes.- Specified by:
removeInstancein interfaceIIngredientCollectionLikeMultiClassifiedTrait<T,M, T, IngredientCollectionSingleClassified<T, M, ?, ?>> - Parameters:
collection- A collection-like.iterableInstance- An iterator instance.
-
getClassifiedCollections
public Map<IngredientComponentCategoryType<T,M, getClassifiedCollections()?>, IngredientCollectionSingleClassified<T, M, ?, ?>> - Specified by:
getClassifiedCollectionsin interfaceIIngredientCollectionLikeMultiClassifiedTrait<T,M, T, IngredientCollectionSingleClassified<T, M, ?, ?>> - Returns:
- A mapping of all internal classified collections.
-