Class EnumOrderedSet<K extends Enum<?>>

java.lang.Object
squidpony.squidmath.OrderedSet<K>
squidpony.squidmath.EnumOrderedSet<K>
All Implemented Interfaces:
Serializable, Cloneable, Iterable<K>, Collection<K>, Set<K>, SortedSet<K>

public class EnumOrderedSet<K extends Enum<?>>
extends OrderedSet<K>
A simple Set of Enum items (which are already unique if used in a normal Set) that keeps insertion order. By inheriting from OrderedSet, it gets features not present in normal JDK Sets, such as retrieval of random items with OrderedSet.randomItem(IRNG), iteration in insertion order instead of always using enum declaration order (order can be shuffled with OrderedSet.shuffle(IRNG) or reordered with OrderedSet.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 EnumOrderedMap.
Created by Tommy Ettinger on 10/21/2017.
See Also:
Serialized Form