I have suffered about JumboEnumSet, but did not find much information about.
when and why do we use JumboEnumSet.Please can anyone explain about JumboEnumSet?
The EnumSet is one of the specialized implementations of the Set interface for use with the enumeration type. A few important features of EnumSet are as follows: It extends AbstractSet class and implements Set Interface in Java. EnumSet class is a member of the Java Collections Framework & is not synchronized.
An EnumSet is a specialized Set collection to work with enum classes. It implements the Set interface and extends from AbstractSet: Even though AbstractSet and AbstractCollection provide implementations for almost all the methods of the Set and Collection interfaces, EnumSet overrides most of them.
Yes EnumSet is modifiable. If you want to create an immutable EnumSet then go for immutableEnumSet. Returns an immutable set instance containing the given enum elements. Internally, the returned set will be backed by an EnumSet .
You don't need to use it explicitly - it's just an implementation detail. Basically, when an enum is small, EnumSet
can use a very efficient representation of the enum as a single int
or long
(I forget which) with one bit per member. When it has more elements than that representation allows, JumboEnumSet
is used instead.
You don't need to worry about this - just use the members on EnumSet
and you'll be fine. Just be aware that if your enums go over a certain size, then enum sets become more expensive and less efficient.
Don't worry about it.
You can't use the class directly because it is declared as package private. And you shouldn't, since it is described in its javadoc as a "private implementation class".
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