Skip to content

Instantly share code, notes, and snippets.

@ochilab
Created November 17, 2020 08:12
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 ochilab/fdf70b86f5f3e6eff81397ba07398aea to your computer and use it in GitHub Desktop.
Save ochilab/fdf70b86f5f3e6eff81397ba07398aea to your computer and use it in GitHub Desktop.
ハッシュテーブルにおけるオープンアドレス法
Bucket *SearchOpenBucket(Hash *h, Data x){
int i;
int key = hash(x.no); /* 探索するデータのハッシュ値 */
Bucket *p = &h->table[key]; /* 着目ノード */
for (i = 0; p->stat != Empty && i < h->size; i++) {
if (p->stat == Occupied && p->data.no == x.no)
return (p);
key = rehash(key);
p = &h->table[key];
}
return (NULL);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment