Package squidpony.squidmath
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
Created by Tommy Ettinger on 10/21/2017.
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
-
Field Summary
Fields inherited from class squidpony.squidmath.OrderedSet
containsNull, DEFAULT_INITIAL_SIZE, DEFAULT_LOAD_FACTOR, f, FAST_LOAD_FACTOR, hasher, key, mask, maxFill, n, order, size, VERY_FAST_LOAD_FACTOR
-
Constructor Summary
Constructors Constructor Description EnumOrderedSet()
EnumOrderedSet(Class<K> enumClass)
EnumOrderedSet(K enumObject)
-
Method Summary
Methods inherited from class squidpony.squidmath.OrderedSet
add, addAll, addAll, addAndMoveToFirst, addAndMoveToLast, addAt, addOrGet, alter, alterAt, arraySize, clear, clone, comparator, contains, containsAll, equals, first, fixOrder, fixOrder, get, getAt, hash64, hashCode, headSet, indexOf, isEmpty, iterator, last, maxFill, maxFill, positionOf, randomItem, rehash, rem, remove, removeAll, removeAt, removeFirst, removeLast, reorder, retainAll, reverse, shiftKeys, shuffle, size, sort, sort, subSet, swap, swapIndices, tailSet, toArray, toArray, trim, trim
-
Constructor Details
-
Method Details
-
toString
- Overrides:
toString
in classOrderedSet<K extends Enum<?>>
-