A sparse bitset is a large collection of boolean values where many of the values are off (or false). For maintaining these sparsely populated sets, the BitSet class can be very inefficient. Since the majority of the bits will be off, space will be occupied to store nothing. For working with these sparse bitsets, you can create an alternate representation, backed instead by a hashtable, or HashMap. Only those positions where a value is set are then stored in the mapping
Yes, you inherit all of the instance variables of the BitSet class, if that's what you mean by "default storage". (It does help if you use the standard names for things, you know.)
A size of 64 isn't going to be a problem, though. The problem is when you start adding larger numbers to the underlying storage, which you won't be doing. Though you may be able to use the BitSet constructor that takes an argument to reduce the storage allocation.
Yogesh Gnanapraksam wrote:
A size of 64 isn't going to be a problem, though. The problem is when you start adding larger numbers to the underlying storage, which you won't be doing. Though you may be able to use the BitSet constructor that takes an argument to reduce the storage allocation.
This gives me some insight. I was thinking about how to control this initial size in a sparse bit set and make it efficient. Now I can work on the exercise to make it efficient for large bit sets.
Yogesh Gnanapraksam wrote:Can you please confirm whether the above code implements your suggestion ?
Don't get me started about those stupid light bulbs. |