1#ifndef __LIB_KERNEL_HASH_H
2#define __LIB_KERNEL_HASH_H
39#define hash_entry(HASH_ELEM, STRUCT, MEMBER) \
40 ((STRUCT *) ((uint8_t *) &(HASH_ELEM)->list_elem \
41 - offsetof (STRUCT, MEMBER.list_elem)))
struct hash_elem * hash_find(struct hash *, struct hash_elem *)
Finds and returns an element equal to E in hash table H, or a null pointer if no equal element exists...
unsigned hash_bytes(const void *, size_t)
Sample hash functions.
struct hash_elem * hash_insert(struct hash *, struct hash_elem *)
Search, insertion, deletion.
bool hash_less_func(const struct hash_elem *a, const struct hash_elem *b, void *aux)
Compares the value of two hash elements A and B, given auxiliary data AUX.
void hash_destroy(struct hash *, hash_action_func *)
Destroys hash table H.
size_t hash_size(struct hash *)
Information.
void hash_first(struct hash_iterator *, struct hash *)
Initializes I for iterating hash table H.
struct hash_elem * hash_delete(struct hash *, struct hash_elem *)
Finds, removes, and returns an element equal to E in hash table H.
void hash_apply(struct hash *, hash_action_func *)
Iteration.
bool hash_init(struct hash *, hash_hash_func *, hash_less_func *, void *aux)
Basic life cycle.
unsigned hash_string(const char *)
Returns a hash of string S.
struct hash_elem * hash_replace(struct hash *, struct hash_elem *)
Inserts NEW into hash table H, replacing any equal element already in the table, which is returned.
struct hash_elem * hash_cur(struct hash_iterator *)
Returns the current element in the hash table iteration, or a null pointer at the end of the table.
unsigned hash_hash_func(const struct hash_elem *e, void *aux)
Computes and returns the hash value for hash element E, given auxiliary data AUX.
bool hash_empty(struct hash *)
Returns true if H contains no elements, false otherwise.
unsigned hash_int(int)
lib/kernel/hash.h
void hash_action_func(struct hash_elem *e, void *aux)
Performs some operation on hash element E, given auxiliary data AUX.
struct hash_elem * hash_next(struct hash_iterator *)
Advances I to the next element in the hash table and returns it.
void hash_clear(struct hash *, hash_action_func *)
Removes all the elements from H.
struct hash * hash
The hash table.
struct list * bucket
Current bucket.
struct hash_elem * elem
Current hash element in current bucket.
hash_less_func * less
Comparison function.
hash_hash_func * hash
Hash function.
void * aux
Auxiliary data for ‘hash’ and ‘less’.
size_t bucket_cnt
Number of buckets, a power of 2.
struct list * buckets
Array of ‘bucket_cnt’ lists.
size_t elem_cnt
Number of elements in table.