In terms of memory, the documentation for BitSet has pretty obvious implications. In particular:
Each bit has a current size, which is the number of bits of space the bit is currently in use. Note that size is related to the implementation of the bit set, so it may change with the implementation. bit set length refers to the logical length of the bit set and is determined independently of the implementation.
The source code for the Java library classes is openly available, and you can easily verify this for yourself . In particular:
The internal field corresponding to the serialField "bits". 89 90 private long[] words;
As for speed; it depends on what he does. In general, do not think about speed ahead of time; use any tool that is most convenient for semantics and leads to the clearest code. Optimize only after you notice that performance requirements are not being met and bottlenecks are identified.
Coming to SO and asking if A is faster than B is stupid for many reasons, including but not limited to:
- It depends on the application, which no one in general has access to. Analyze and profile it in the context in which it is used. Make sure this is a bottleneck that is really worth optimizing.
- Questions like this, which ask speed, usually indicate that the OP thinks they care about efficiency, but do not want to profile and do not define performance requirements. Under the surface, usually a red flag, that the OP is moving in the wrong way.
I know this is an old question, but it has appeared recently; and I think it's worth adding.
Jason C Nov 05 '13 at 12:14 2013-11-05 12:14
source share