1. Conflict resolution based on separation chain
1.1 Main storage structure
struct ListNode
{
ElementType Element;
Position Next;
};
This is the structure that stores the data and is actually a linked list.
typedef struct ListNode *Position;
typedef Position List;
struct HashTbl
{
int TableSize;//哈希表大小
List *TheLists;//指针数组
};
This is the hash table main structure, *thelists is an array of pointers, each item of the array is linked to one of the above ListNode, and this entry address corresponds to the Chain header node.
1.2ADT description
hashsep.h
typedef int ElementType;
#ifndef HASHSEP_H_INCLUDED
#define HASHSEP_H_INCLUDED
typedef unsigned int Index;
struct ListNode;
typedef struct ListNode *Position;
struct HashTbl;
typedef struct HashTbl *HashTable;
HashTable InitializeTable( int TableSize );
void DestroyTable( HashTable H );
Position Find( ElementType Key, HashTable H );
void Insert( ElementType Key, HashTable H );
ElementType Retrieve( Position P );
/* Routines such as Delete are MakeEmpty are omitted */
#endif // HASHSEP_H_INCLUDED