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
Returns the number of cells in a hash table. */
32
/* out: number of cells */
33
hash_table_t* table) /* in: table */
35
return(table->n_cells);
38
/******************************************************************
39
Calculates the hash value from a folded value. */
44
/* out: hashed value */
45
ulint fold, /* in: folded value */
46
hash_table_t* table) /* in: hash table */
48
return(ut_hash_ulint(fold, table->n_cells));
51
/****************************************************************
52
Gets the mutex index for a fold value in a hash table. */
57
/* out: mutex number */
58
hash_table_t* table, /* in: hash table */
59
ulint fold) /* in: fold */
61
return(ut_2pow_remainder(fold, table->n_mutexes));
64
/****************************************************************
65
Gets the nth heap in a hash table. */
71
hash_table_t* table, /* in: hash table */
72
ulint i) /* in: index of the heap */
74
ut_ad(i < table->n_mutexes);
76
return(table->heaps[i]);
79
/****************************************************************
80
Gets the heap for a fold value in a hash table. */
86
hash_table_t* table, /* in: hash table */
87
ulint fold) /* in: fold */
95
i = hash_get_mutex_no(table, fold);
97
return(hash_get_nth_heap(table, i));
100
/****************************************************************
101
Gets the nth mutex in a hash table. */
107
hash_table_t* table, /* in: hash table */
108
ulint i) /* in: index of the mutex */
110
ut_ad(i < table->n_mutexes);
112
return(table->mutexes + i);
115
/****************************************************************
116
Gets the mutex for a fold value in a hash table. */
122
hash_table_t* table, /* in: hash table */
123
ulint fold) /* in: fold */
127
i = hash_get_mutex_no(table, fold);
129
return(hash_get_nth_mutex(table, i));