1) EnumSet is a special Set implementation, only applicable for Enums in Java, but you can only store instances of single enum type. Adding instance of different enum will result in compile time error, as EnumSet provide type-safety.
2) EnumSet internal representation is extremely efficient and represented as bit vectors. Library itself chooses one of two implementation available depending upon size of key universe. RegularEnumSet is chosen if number of instances is less than 64, otherwise JumboEnumSet is used.
4) Iterator returned by EnumSet traverse the elements in their natural order, i.e. the order on which enum constants are declared, or the order returned by ordinal() method.
7) EnumSet is an abstract class, which means you cannot create its instance using new() operator.
The EnumSet class provides three benefits a normal set does not:
Guaranteed ordering of the elements in the set based on their order in the enumeration constants are declared
Performance and memory benefits not nearly possible with a regular set implementation
Read full article from How to use EnumSet in Java with Example
2) EnumSet internal representation is extremely efficient and represented as bit vectors. Library itself chooses one of two implementation available depending upon size of key universe. RegularEnumSet is chosen if number of instances is less than 64, otherwise JumboEnumSet is used.
4) Iterator returned by EnumSet traverse the elements in their natural order, i.e. the order on which enum constants are declared, or the order returned by ordinal() method.
7) EnumSet is an abstract class, which means you cannot create its instance using new() operator.
The EnumSet class provides three benefits a normal set does not:
Guaranteed ordering of the elements in the set based on their order in the enumeration constants are declared
Performance and memory benefits not nearly possible with a regular set implementation
Read full article from How to use EnumSet in Java with Example
No comments:
Post a Comment