Created
August 10, 2016 15:13
-
-
Save matriv/29a64826d6690810ac1b9f5096ba98c2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private class CustomBitSetList { | |
final int bucket_size = 1024; | |
int offset = -1; | |
int currentBucketIdx = 0; | |
ArrayList<FixedBitSet> buckets = new ArrayList<>(16); | |
FixedBitSet currentBucket = new FixedBitSet(bucket_size); | |
CustomBitSetList() { | |
buckets.add(currentBucket); | |
} | |
void setNext(boolean bit) { | |
offset++; | |
if (offset == bucket_size) { | |
currentBucket = new FixedBitSet(bucket_size); | |
buckets.add(currentBucket); | |
offset = 0; | |
} | |
if (bit) { | |
currentBucket.set(offset); | |
} | |
} | |
boolean getNext() { | |
offset++; | |
if (offset == bucket_size) { | |
currentBucketIdx++; | |
currentBucket = buckets.get(currentBucketIdx); | |
offset = 0; | |
} | |
return currentBucket.get(offset); | |
} | |
void readMode() { | |
offset = -1; | |
currentBucket = buckets.get(0); | |
currentBucketIdx = 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment