Hi,
I sub classed the BitSet class to add some additional methods. One of the is called "fold". It splits the BitSet in 2 halves and "combines" them with an or. (increases Information density)
This works but the size (1024) of the folded BitSet is still the original size.
Code:
BitSet firstHalf;
BitSet secondHalf;
for(int i = nrOfTimes; i > 0; i-- ){
firstHalf = this.get(0, this.size()/2);
secondHalf = this.get(this.size()/2, this.size());
firstHalf.or(secondHalf);
this.clear();
this.or(firstHalf);
}
It's probably doable to return a new BitSet of desired length but only by creating a new smaller one for each iteration but still you would need to re-assign it (myClass = myClass.fold()). If you fold, there is no interest in the original version. The idea is to save space (memory and DB).
Is there a way to reduce the size of the current BitSet? (a "trick" I'm not seeing?)