Created
February 14, 2019 05:13
-
-
Save schellingb/807db6d738b881d54d55354eb3def50c to your computer and use it in GitHub Desktop.
This file contains 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
bool AreAllBitsInRangeSet(int from, int end) //check range from (inclusive) to end (exclusive) | |
{ | |
int f64 = (from&~63), e64 = (end&~63); | |
for (int i = f64 + 64; i < e64; i += 64) { if ((ULongBitArray[i>>6]) != ~0UL) return false; } | |
ulong fMask = (~0UL<<(from-f64)), eMask = ((1UL<<(end-e64))-1); | |
if (f64 == e64) { fMask = (fMask&eMask); eMask = 0; } | |
return ((ULongBitArray[f64>>6] & fMask) == fMask && (eMask == 0 || (ULongBitArray[e64>>6] & eMask) != eMask)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment