Skip to content

Instantly share code, notes, and snippets.

@HaiyangXu
Created January 3, 2015 15:00
Show Gist options
  • Save HaiyangXu/596833e6aa77e3e5a140 to your computer and use it in GitHub Desktop.
Save HaiyangXu/596833e6aa77e3e5a140 to your computer and use it in GitHub Desktop.
#define BITSPERWORD sizeof(int)*8
#define SHIFT 5
#define MASK 0x1f
#define N 10000000
int a[1+N/BITSPERWORD];
void set(int i){
a[i/BITSPERWORD]|=(1<<(i%BITSPERWORD));
}
void clr(int i){
a[i/BITSPERWORD]&=~(1<<(i%BITSPERWORD));
}
int test(int i){
return a[i/BITSPERWORD]&(1<<(i%BITSPERWORD));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment