- #define MASK 0X1F
- #define SHIFT 5
- #define WORD 32 // the bits of a word
- #define N 10000000 //the max number
- int bitmap[N/WORD];
- void bitmap_set(int i){
- bitmap[i>>SHIFT] |= 1 << (i & MASK);
- }
- int bitmap_test(int i){
- return bitmap[i>>SHIFT] & (1 << (i&MASK));
- }
- void bitmap_clear(int i){
- bitmap[i>>SHIFT] &= ~(1 << (i & MASK));
- }
- //该片段来自于http://www.codesnippet.cn/detail/170720134655.html
来源: http://www.codesnippet.cn/detail/170720134655.html