Class IngredientMapSingleClassified<T,M,V,C>
java.lang.Object
org.cyclops.cyclopscore.ingredient.collection.IngredientMapAdapter<T,M,V>
org.cyclops.cyclopscore.ingredient.collection.IngredientMapSingleClassified<T,M,V,C>
- Type Parameters:
T- The instance type.M- The matching condition parameter.V- The type of mapped values.C- The category type.
- All Implemented Interfaces:
Iterable<Map.Entry<T,,V>> IIngredientCollectionLike<T,,M, Map.Entry<T, V>> IIngredientCollectionLikeSingleClassifiedTrait<T,,M, Map.Entry<T, V>, C, IIngredientMapMutable<T, M, V>> IIngredientMap<T,,M, V> IIngredientMapMutable<T,M, V>
public class IngredientMapSingleClassified<T,M,V,C>
extends IngredientMapAdapter<T,M,V>
implements IIngredientCollectionLikeSingleClassifiedTrait<T,M,Map.Entry<T,V>,C,IIngredientMapMutable<T,M,V>>
An ingredient map 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
ConstructorsConstructorDescriptionIngredientMapSingleClassified(IngredientComponent<T, M> component, Supplier<IIngredientMapMutable<T, M, V>> mapCreator, IngredientComponentCategoryType<T, M, C> categoryType) Create a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears this map of all instances.booleancontainsKey(T instance, M matchCondition) Check if this map contains the given instance under the given match conditions.booleancontainsValue(V value) Check if this map contains the given value.intCount the number of occurrences of the given instance under the given match conditions.Get the value for the given instance.Get all values for all instances that match with the given instance under the given match conditions.getInstance(Map.Entry<T, V> 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.keySet()Get all key instances that match the given instance.Add a new entry.Remove the mapping for the given key instance.voidsetSize(int size) Set the internal size value.intsize()values()Methods inherited from class org.cyclops.cyclopscore.ingredient.collection.IngredientMapAdapter
entrySet, equals, getComponent, hashCode, removeAll, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionLike
equals, getComponent, hashCode, isEmpty, toStringMethods inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientCollectionLikeSingleClassifiedTrait
appliesToClassifier, getClassifier, getOrCreateClassifiedCollectionMethods inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientMap
containsKey, containsKeyAll, containsKeyAllMethods inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientMapMutable
putAll, removeAll, removeAllMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
IngredientMapSingleClassified
public IngredientMapSingleClassified(IngredientComponent<T, M> component, Supplier<IIngredientMapMutable<T, M, V>> mapCreator, IngredientComponentCategoryType<T, M, C> categoryType) Create a new instance.- Parameters:
component- A component type.mapCreator- A callback for creating new internal maps for a single classifier.categoryType- A category type using which this collection will classify instance.
-
-
Method Details
-
getCategoryType
- Specified by:
getCategoryTypein interfaceIIngredientCollectionLikeSingleClassifiedTrait<T,M, Map.Entry<T, V>, C, IIngredientMapMutable<T, M, V>> - Returns:
- The category type using which this collection classifies.
-
createEmptyCollection
- Specified by:
createEmptyCollectionin interfaceIIngredientCollectionLikeSingleClassifiedTrait<T,M, Map.Entry<T, V>, C, IIngredientMapMutable<T, M, V>> - 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, Map.Entry<T, V>, C, IIngredientMapMutable<T, M, V>> - Parameters:
iterableInstance- An iterator instance.- Returns:
- An instance.
-
getClassifiedCollections
- Specified by:
getClassifiedCollectionsin interfaceIIngredientCollectionLikeSingleClassifiedTrait<T,M, Map.Entry<T, V>, C, IIngredientMapMutable<T, M, V>> - 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. -
clear
public void clear()Description copied from interface:IIngredientMapMutableClears this map of all instances.- Specified by:
clearin interfaceIIngredientMapMutable<T,M, V>
-
put
Description copied from interface:IIngredientMapMutableAdd a new entry.- Specified by:
putin interfaceIIngredientMapMutable<T,M, V> - Parameters:
key- An instance key.value- A value.- Returns:
- The previous value that was associated with the given instance.
-
remove
Description copied from interface:IIngredientMapMutableRemove the mapping for the given key instance.- Specified by:
removein interfaceIIngredientMapMutable<T,M, V> - Parameters:
key- An instance key.- Returns:
- The value that was associated with the given instance.
-
size
public int size()- Specified by:
sizein interfaceIIngredientCollectionLike<T,M, V> - Returns:
- The number of instances contained in this collection.
-
containsKey
Description copied from interface:IIngredientMapCheck if this map 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:
containsKeyin interfaceIIngredientMap<T,M, V> - Parameters:
instance- An instance.matchCondition- A match condition.- Returns:
- If this map contains the given instance under the given match conditions.
-
countKey
Description copied from interface:IIngredientMapCount 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:
countKeyin interfaceIIngredientMap<T,M, V> - Parameters:
instance- An instance.matchCondition- A match condition.- Returns:
- The number of occurrences of the given instance under the given match conditions.
-
containsValue
Description copied from interface:IIngredientMapCheck if this map contains the given value.- Specified by:
containsValuein interfaceIIngredientMap<T,M, V> - Parameters:
value- A value.- Returns:
- If this map contains the given value.
-
get
Description copied from interface:IIngredientMapGet the value for the given instance.- Specified by:
getin interfaceIIngredientMap<T,M, V> - Parameters:
key- An instance.- Returns:
- The value.
-
keySet
- Specified by:
keySetin interfaceIIngredientMap<T,M, V> - Returns:
- All key instances.
-
values
- Specified by:
valuesin interfaceIIngredientMap<T,M, V> - Returns:
- All values.
-
getAll
Description copied from interface:IIngredientMapGet all values for all instances that match with 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:
getAllin interfaceIIngredientMap<T,M, V> - Overrides:
getAllin classIngredientMapAdapter<T,M, V> - Parameters:
key- An instance.matchCondition- A match condition.- Returns:
- All matching values.
-
keySet
Description copied from interface:IIngredientMapGet all key instances that match the given instance. This instance will be compared based on the matcher from the ingredient component type using the given match condition.- Specified by:
keySetin interfaceIIngredientMap<T,M, V> - Overrides:
keySetin classIngredientMapAdapter<T,M, V> - Parameters:
key- An instance.matchCondition- A match condition.- Returns:
- All key instances that match the given instance.
-
iterator
-
iterator
Description copied from interface:IIngredientCollectionLikeAn iterator over this collection over all occurrences of the given instance under the given match conditions.- Specified by:
iteratorin interfaceIIngredientCollectionLike<T,M, V> - Overrides:
iteratorin classIngredientMapAdapter<T,M, V> - 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.
-