Skip to content

Instantly share code, notes, and snippets.

@gamemachine
Created March 12, 2019 23:27
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 gamemachine/fa08afc83c8376cf9ca8fe52e1f19a94 to your computer and use it in GitHub Desktop.
Save gamemachine/fa08afc83c8376cf9ca8fe52e1f19a94 to your computer and use it in GitHub Desktop.
public struct BitMask
{
private static int[] Masks;
private BitVector32 Vector;
static BitMask()
{
Masks = new int[32];
{
Masks[0] = BitVector32.CreateMask();
}
for (int i = 1; i < 32; i++)
{
Masks[i] = BitVector32.CreateMask(Masks[i - 1]);
}
}
public int Data
{
get
{
return Vector.Data;
}
}
public BitMask(int data)
{
Vector = new BitVector32(data);
}
public bool IsSet(int position)
{
return Vector[Masks[position]];
}
public void Set(int position, bool flag)
{
Vector[Masks[position]] = flag;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment