Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schellingb/807db6d738b881d54d55354eb3def50c to your computer and use it in GitHub Desktop.
Save schellingb/807db6d738b881d54d55354eb3def50c to your computer and use it in GitHub Desktop.
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