了解链接列表哈希表的实现

时间:2019-05-22 22:31:07

标签: c hash

/* a bucket is a linked list, each of whose entries contains a string and its hash */

typedef struct bucket bucket;
struct bucket {
  char *string;
  unsigned long int hash;
  bucket *next;
};
/* By convention, the empty bucket is NULL. */

typedef struct hash_table htbl;
struct hash_table {
  unsigned long int(*hash)(char*);
  bucket **buckets; /* an array of buckets */
  unsigned int n_buckets;
};

我试图了解hash_table结构。具体来说,unsigned long int(*hash)(char*);的目的和用途是什么?我觉得没有它我可以实现一个哈希表。任何帮助将不胜感激。谢谢!

0 个答案:

没有答案