1
/******************************************************
2
The simple hash table utility
6
Created 5/20/1997 Heikki Tuuri
7
*******************************************************/
11
/****************************************************************
12
Gets the nth cell in a hash table. */
17
/* out: pointer to cell */
18
hash_table_t* table, /* in: hash table */
19
ulint n) /* in: cell index */
21
ut_ad(n < table->n_cells);
23
return(table->array + n);
26
/*****************************************************************
27
Clears a hash table so that all the cells become empty. */
32
hash_table_t* table) /* in/out: hash table */
34
memset(table->array, 0x0,
35
table->n_cells * sizeof(*table->array));
38
/*****************************************************************
39
Returns the number of cells in a hash table. */
44
/* out: number of cells */
45
hash_table_t* table) /* in: table */
47
return(table->n_cells);
50
/******************************************************************
51
Calculates the hash value from a folded value. */
56
/* out: hashed value */
57
ulint fold, /* in: folded value */
58
hash_table_t* table) /* in: hash table */
60
return(ut_hash_ulint(fold, table->n_cells));
63
/****************************************************************
64
Gets the mutex index for a fold value in a hash table. */
69
/* out: mutex number */
70
hash_table_t* table, /* in: hash table */
71
ulint fold) /* in: fold */
73
ut_ad(ut_is_2pow(table->n_mutexes));
74
return(ut_2pow_remainder(fold, table->n_mutexes));
77
/****************************************************************
78
Gets the nth heap in a hash table. */
84
hash_table_t* table, /* in: hash table */
85
ulint i) /* in: index of the heap */
87
ut_ad(i < table->n_mutexes);
89
return(table->heaps[i]);
92
/****************************************************************
93
Gets the heap for a fold value in a hash table. */
99
hash_table_t* table, /* in: hash table */
100
ulint fold) /* in: fold */
108
i = hash_get_mutex_no(table, fold);
110
return(hash_get_nth_heap(table, i));
113
/****************************************************************
114
Gets the nth mutex in a hash table. */
120
hash_table_t* table, /* in: hash table */
121
ulint i) /* in: index of the mutex */
123
ut_ad(i < table->n_mutexes);
125
return(table->mutexes + i);
128
/****************************************************************
129
Gets the mutex for a fold value in a hash table. */
135
hash_table_t* table, /* in: hash table */
136
ulint fold) /* in: fold */
140
i = hash_get_mutex_no(table, fold);
142
return(hash_get_nth_mutex(table, i));