-
Notifications
You must be signed in to change notification settings - Fork 1
/
BitMask.cs
45 lines (44 loc) · 1.04 KB
/
BitMask.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Lethargy
{
public class BitMask
{
private int mask;
public BitMask(int num)
{
this.mask = num;
}
public bool BitOn(int num)
{
return Conversions.ToBoolean(Interaction.IIf((this.mask & 1 << checked(32 - num)) > 0, true, false));
}
public void SetBit(int num)
{
this.mask |= 1 << checked(32 - num);
}
public void ToggleBit(int num)
{
checked
{
if ((this.mask & 1 << 32 - num) > 0)
{
this.mask &= ~(1 << 32 - num);
}
else
{
this.mask |= 1 << 32 - num;
}
}
}
public int ToInt()
{
return this.mask;
}
}
}