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
ConstructorDescriptionIngredientMapSingleClassified
(IngredientComponent<T, M> component, Supplier<IIngredientMapMutable<T, M, V>> mapCreator, IngredientComponentCategoryType<T, M, C> categoryType) Create a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears this map of all instances.boolean
containsKey
(T instance, M matchCondition) Check if this map contains the given instance under the given match conditions.boolean
containsValue
(V value) Check if this map contains the given value.int
Count 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.void
setSize
(int size) Set the internal size value.int
size()
values()
Methods inherited from class org.cyclops.cyclopscore.ingredient.collection.IngredientMapAdapter
entrySet, equals, getComponent, hashCode, removeAll, 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.IIngredientCollectionLike
equals, 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.IIngredientMap
containsKey, containsKeyAll, containsKeyAll
Methods inherited from interface org.cyclops.cyclopscore.ingredient.collection.IIngredientMapMutable
putAll, removeAll, removeAll
Methods 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:
getCategoryType
in interfaceIIngredientCollectionLikeSingleClassifiedTrait<T,
M, Map.Entry<T, V>, C, IIngredientMapMutable<T, M, V>> - Returns:
- The category type using which this collection classifies.
-
createEmptyCollection
- Specified by:
createEmptyCollection
in 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: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, Map.Entry<T, V>, C, IIngredientMapMutable<T, M, V>> - Parameters:
iterableInstance
- An iterator instance.- Returns:
- An instance.
-
getClassifiedCollections
- Specified by:
getClassifiedCollections
in 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:IIngredientCollectionLikeSingleClassifiedTrait
Set 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:IIngredientMapMutable
Clears this map of all instances.- Specified by:
clear
in interfaceIIngredientMapMutable<T,
M, V>
-
put
Description copied from interface:IIngredientMapMutable
Add a new entry.- Specified by:
put
in 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:IIngredientMapMutable
Remove the mapping for the given key instance.- Specified by:
remove
in 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:
size
in interfaceIIngredientCollectionLike<T,
M, V> - Returns:
- The number of instances contained in this collection.
-
containsKey
Description copied from interface:IIngredientMap
Check 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:
containsKey
in 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:IIngredientMap
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:
countKey
in 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:IIngredientMap
Check if this map contains the given value.- Specified by:
containsValue
in interfaceIIngredientMap<T,
M, V> - Parameters:
value
- A value.- Returns:
- If this map contains the given value.
-
get
Description copied from interface:IIngredientMap
Get the value for the given instance.- Specified by:
get
in interfaceIIngredientMap<T,
M, V> - Parameters:
key
- An instance.- Returns:
- The value.
-
keySet
- Specified by:
keySet
in interfaceIIngredientMap<T,
M, V> - Returns:
- All key instances.
-
values
- Specified by:
values
in interfaceIIngredientMap<T,
M, V> - Returns:
- All values.
-
getAll
Description copied from interface:IIngredientMap
Get 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:
getAll
in interfaceIIngredientMap<T,
M, V> - Overrides:
getAll
in classIngredientMapAdapter<T,
M, V> - Parameters:
key
- An instance.matchCondition
- A match condition.- Returns:
- All matching values.
-
keySet
Description copied from interface:IIngredientMap
Get 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:
keySet
in interfaceIIngredientMap<T,
M, V> - Overrides:
keySet
in 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:IIngredientCollectionLike
An iterator over this collection over all occurrences of the given instance under the given match conditions.- Specified by:
iterator
in interfaceIIngredientCollectionLike<T,
M, V> - Overrides:
iterator
in 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.
-