Questions tagged [enumset]

A specialized Set implementation for use with enum types. EnumSet class exists to take advantage of the efficient implementations that are possible when the number of possible elements is fixed and a unique index can be assigned to each.

A specialized Set implementation for use with enum types. EnumSet class exists to take advantage of the efficient implementations that are possible when the number of possible elements is fixed and a unique index can be assigned to each.

All of the elements in an enum set must come from a single enum type that is specified, explicitly or implicitly, when the set is created. Enum sets are represented internally as bit vectors. This representation is extremely compact and efficient. The space and time performance of this class should be good enough to allow its use as a high-quality, typesafe alternative to traditional int-based "bit flags." Even bulk operations (such as containsAll and retainAll) should run very quickly if their argument is also an enum set.

98 questions
0
votes
2 answers

Should I use an EnumSet?

I am trying to build a "flat file reader." These files will have several related columns, such as "Customer Name", "Telephone," etc, but the column number will be different for each flat file; also, some flat files will have columns that others…
0
votes
2 answers

How the limit number of enumeration in EnumSet come from?

I found that a limit number of enumeration (64) is used in EnumSet. Please see a method in EnumSet source code below (This code is captured from JDK 1.7). /** * Creates an empty enum set with the specified element type. * * @param elementType…
Mengjun
  • 3,159
  • 1
  • 15
  • 21
0
votes
1 answer

Writing a generic enumset widget in Java - can't get the syntax right

I'm trying to write a generic widget that takes a (any) enumset and pops up a simple form to allow the the individual enums to be turned on and off. Below is a minimal version of the class (actually set up to run on android), but eclipse is moaning…
pootle
  • 507
  • 6
  • 15
0
votes
2 answers

My generic EnumSet method - can't access Enum.values()

I'm trying to write a generic method for initializing an EnumSet value from an integer containing a bit mask. I'm getting a compiler error I don't understand. Here's my code: private > void setEnumSet( EnumSet es, int iEnum…
jbirkel
  • 27
  • 2
-1
votes
1 answer

How to create an EnumSet of a collection of unspecified objects

Given data: I am presented with a collection: Collection collection This collection may contain anything. It could be "normal" classes, or it could be enum values. The class is known at this point in my code. I am given: Class clazz Which is…
jaylawl
  • 105
  • 6
-1
votes
1 answer

Java EnumSet - Add and check if set contains a flag

I am trying to understand how to properly use EnumSet for an equivalent to C#'s Flags. Here is my implementation and methods that use this. As you can see, checking if a flag exists is not working properly. Can you please let me know what I am…
blgrnboy
  • 4,877
  • 10
  • 43
  • 94
-2
votes
1 answer

Caching enum values

I have more enums with some values and I want asked you what the method is good to cache enum values: For example: public enum Animal { Dog, Cat, Cow; static Animal[] values; static EnumSet cachedAnimalsEnumSet; static List
-2
votes
2 answers

using enum with large set of items c#

h every body im using enum in c#.net and my set of data is about 300 items in iis on windows 10: when i use enum like this: enum EnumSet{ item1,item2,... item300 } switch enumset{ case EnumSet.Item1: { //Do something break; …
mpourbafrani
  • 109
  • 1
  • 2
  • 7
1 2 3 4 5 6
7