I want to have all the efficiencies of EnumSet and pass it around without worrying that somebody would modify it.
An enumSet is a Java Collections member, it is not synchronized. An enumSet is a high performing set implementation that works faster than the HashSet. All the elements in an enumSet must be of a single enumeration type that is specified when the set is created.
Yes EnumSet is modifiable.
Use EnumSet. noneOf(Class) to create an empty EnumSet.
Methods of EnumSetCreates an enum set initialized from the specified collection. Creates an enum set with the same element type as the specified enum set, initially containing the same elements (if any). Creates an empty enum set with the specified element type.
You can get an immutable EnumSet with Google collections (Guava).
Resources :
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With