java.lang.Object
gg.xp.xivapi.collections.KeyedAlikeMapFactory<K>
- Type Parameters:
K- The key type.
KeyedAlikeMapFactory is used to take a set of allowed keys, and produce many
KeyedAlikeMap instances from it.
To use, specify your key set in the constructor. Then, use create() in either form to create a map instance.
Every KeyedAlikeMap instance created by a KeyedAlikeMapFactory will share the same underlying map, and store the
actual values in an array. This saves memory in a similar manner to Python's "slots".
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionKeyedAlikeMapFactory(Set<K> keys) Constructs a KeyedAlikeMapFactory for the given set of keys.KeyedAlikeMapFactory(Set<K> keys, KeySerDe<K, ?> serDe) Constructor that also accepts a serde helper, so that maps with non-serializable keys can still be serialized. -
Method Summary
Modifier and TypeMethodDescription<V> KeyedAlikeMap<K, V> create()Create an empty map<V> KeyedAlikeMap<K, V> Create a map from the given values
-
Constructor Details
-
KeyedAlikeMapFactory
Constructs a KeyedAlikeMapFactory for the given set of keys.Note that resulting maps will only be serializable if the keys are serializable.
- Parameters:
keys- The set of all possible keys.
-
KeyedAlikeMapFactory
Constructor that also accepts a serde helper, so that maps with non-serializable keys can still be serialized.- Parameters:
keys- The keysserDe- A helper to convert the keys to/from a serializable for
-
-
Method Details
-
create
Create an empty map- Type Parameters:
V- The type of values- Returns:
- An empty map
-
create
Create a map from the given values- Type Parameters:
V- The type of values- Parameters:
values- The initial values- Returns:
- A map with the initial values
- Throws:
IllegalArgumentException- when a key in the initial is not in the set of keys handled by this factory
-