Skip to content

Instantly share code, notes, and snippets.

@badamczewski
Created November 10, 2020 20:19
Show Gist options
  • Select an option

  • Save badamczewski/9a5aa6fbec385061b430465ed043bf5b to your computer and use it in GitHub Desktop.

Select an option

Save badamczewski/9a5aa6fbec385061b430465ed043bf5b to your computer and use it in GitHub Desktop.
Bit Set
public class BitSet
{
private ulong[] bitset;
public int Size { get; private set; }
public BitSet(int size)
{
bitset = new ulong[(size / 64) + 1];
Size = size;
}
public void Add(int index)
{
bitset[index / 64] |= (1u << (index % 64));
}
public bool Contains(int index)
{
return (bitset[index / 64] & (1u << (index % 64))) != 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment