Created
December 11, 2013 07:03
-
-
Save Zuckonit/7906154 to your computer and use it in GitHub Desktop.
bitmap
This file contains 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
#define N 1000000 //the max value | |
#define MASK 0x1F | |
int a[1+N/32]; //int has 32 bits | |
void set(int i) { | |
a[i>>5] |= (1 << (i & MASK)); | |
} | |
void clear(int i) { | |
a[i>>5] &= ~(1 << (i & MASK)); | |
} | |
int is_existed(int i) { | |
return a[i>>5] & (1 << (i & MASK)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I take it as a special hashtable