Class EnumOrderedMap<K extends Enum<?>,​V>

java.lang.Object
squidpony.squidmath.OrderedMap<K,​V>
squidpony.squidmath.EnumOrderedMap<K,​V>
All Implemented Interfaces:
Serializable, Cloneable, Map<K,​V>, SortedMap<K,​V>

public class EnumOrderedMap<K extends Enum<?>,​V>
extends OrderedMap<K,​V>
A simple alternative to EnumMap that has a zero-argument constructor (which makes serialization easier) but is a little less efficient. However, it supports more features by inheriting from OrderedMap, such as retrieval of random keys or values with OrderedMap.randomKey(IRNG) and OrderedMap.randomValue(IRNG), iteration in insertion order instead of always using enum declaration order (order can be shuffled with OrderedMap.shuffle(IRNG) or reordered with OrderedMap.reorder(int...)), and a little more. The implementation is nearly trivial due to how OrderedMap allows customization of hashing strategy with its IHasher option, and this class always uses a specific custom IHasher to hash Enum values by their ordinal. This IHasher is shared with EnumOrderedSet.
Created by Tommy Ettinger on 10/21/2017.
See Also:
Serialized Form