Skip to content

Instantly share code, notes, and snippets.

@onemouth
Created July 18, 2019 11:28
Show Gist options
  • Save onemouth/76f52718fd989c8bffe59a6acce758d8 to your computer and use it in GitHub Desktop.
Save onemouth/76f52718fd989c8bffe59a6acce758d8 to your computer and use it in GitHub Desktop.
int ch(int key, int num_buckets) {
random.seed(key);
int b = -1;
int j = 0;
while (j < num_buckets) {
b = j;
double r = random.next();
j = floor((b + 1) / r);
}
return b;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment