1
/************************************************************************
2
The hash table with external chains
4
(c) 1994-1997 Innobase Oy
6
Created 8/18/1994 Heikki Tuuri
7
*************************************************************************/
12
/***************************************************************
13
Deletes a hash node. */
18
hash_table_t* table, /* in: hash table */
19
ha_node_t* del_node); /* in: node to be deleted */
21
/**********************************************************************
22
Gets a hash node data. */
27
/* out: pointer to the data */
28
ha_node_t* node) /* in: hash chain node */
33
/**********************************************************************
34
Sets hash node data. */
39
ha_node_t* node, /* in: hash chain node */
40
void* data) /* in: pointer to the data */
45
/**********************************************************************
46
Gets the next node in a hash chain. */
51
/* out: next node, NULL if none */
52
ha_node_t* node) /* in: hash chain node */
57
/**********************************************************************
58
Gets the first node in a hash chain. */
63
/* out: first node, NULL if none */
64
hash_table_t* table, /* in: hash table */
65
ulint fold) /* in: fold value determining the chain */
67
return(hash_get_nth_cell(table, hash_calc_hash(fold, table))->node);
70
/*****************************************************************
71
Looks for an element in a hash table. */
76
/* out: pointer to the first hash table node
77
in chain having the fold number, NULL if not
79
hash_table_t* table, /* in: hash table */
80
ulint fold) /* in: folded value of the searched data */
84
ut_ad(!table->mutexes || mutex_own(hash_get_mutex(table, fold)));
86
node = ha_chain_get_first(table, fold);
89
if (node->fold == fold) {
94
node = ha_chain_get_next(node);
100
/*****************************************************************
101
Looks for an element in a hash table. */
104
ha_search_and_get_data(
105
/*===================*/
106
/* out: pointer to the data of the first hash
107
table node in chain having the fold number,
109
hash_table_t* table, /* in: hash table */
110
ulint fold) /* in: folded value of the searched data */
114
ut_ad(!table->mutexes || mutex_own(hash_get_mutex(table, fold)));
116
node = ha_chain_get_first(table, fold);
119
if (node->fold == fold) {
124
node = ha_chain_get_next(node);
130
/*************************************************************
131
Looks for an element when we know the pointer to the data. */
136
/* out: pointer to the hash table node, NULL
137
if not found in the table */
138
hash_table_t* table, /* in: hash table */
139
ulint fold, /* in: folded value of the searched data */
140
void* data) /* in: pointer to the data */
144
ut_ad(!table->mutexes || mutex_own(hash_get_mutex(table, fold)));
146
node = ha_chain_get_first(table, fold);
149
if (node->data == data) {
154
node = ha_chain_get_next(node);
160
/*************************************************************
161
Looks for an element when we know the pointer to the data, and deletes
162
it from the hash table, if found. */
165
ha_search_and_delete_if_found(
166
/*==========================*/
167
/* out: TRUE if found */
168
hash_table_t* table, /* in: hash table */
169
ulint fold, /* in: folded value of the searched data */
170
void* data) /* in: pointer to the data */
174
ut_ad(!table->mutexes || mutex_own(hash_get_mutex(table, fold)));
176
node = ha_search_with_data(table, fold, data);
179
ha_delete_hash_node(table, node);