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(hash_calc_hash(fold, table),
65 /****************************************************************
66 Gets the nth heap in a hash table. */
72 hash_table_t* table, /* in: hash table */
73 ulint i) /* in: index of the heap */
75 ut_ad(i < table->n_mutexes);
77 return(table->heaps[i]);
80 /****************************************************************
81 Gets the heap for a fold value in a hash table. */
87 hash_table_t* table, /* in: hash table */
88 ulint fold) /* in: fold */
96 i = hash_get_mutex_no(table, fold);
98 return(hash_get_nth_heap(table, i));
101 /****************************************************************
102 Gets the nth mutex in a hash table. */
108 hash_table_t* table, /* in: hash table */
109 ulint i) /* in: index of the mutex */
111 ut_ad(i < table->n_mutexes);
113 return(table->mutexes + i);
116 /****************************************************************
117 Gets the mutex for a fold value in a hash table. */
123 hash_table_t* table, /* in: hash table */
124 ulint fold) /* in: fold */
128 i = hash_get_mutex_no(table, fold);
130 return(hash_get_nth_mutex(table, i));