Skip to content

Instantly share code, notes, and snippets.

@Zuckonit
Created December 11, 2013 07:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zuckonit/7906154 to your computer and use it in GitHub Desktop.
Save Zuckonit/7906154 to your computer and use it in GitHub Desktop.
bitmap
#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));
}
@Zuckonit
Copy link
Author

I take it as a special hashtable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment