Created
March 12, 2019 23:27
-
-
Save gamemachine/fa08afc83c8376cf9ca8fe52e1f19a94 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
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