MOS Source Code
Loading...
Searching...
No Matches
libs.HashMap

A simple hashmap. More...

+ Collaboration diagram for libs.HashMap:

Topics

 libs.HashMap.Common
 Common hash and comparison functions for hashmaps.
 

Classes

struct  hashmap_t
 

Typedefs

typedef hash_t(* hashmap_hash_t) (const uintn key)
 
typedef int(* hashmap_key_compare_t) (const uintn key1, const uintn key2)
 A hashmap hash function prototype.
 
typedef bool(* hashmap_foreach_func_t) (const uintn key, void *value, void *data)
 A hashmap key comparison function prototype.
 
typedef struct hashmap_entry hashmap_entry_t
 A hashmap foreach callback function prototype.
 

Functions

MOSAPI void hashmap_init (hashmap_t *map, size_t capacity, hashmap_hash_t hash_func, hashmap_key_compare_t compare_func)
 
MOSAPI void hashmap_deinit (hashmap_t *map)
 Deinitialize a hashmap.
 
MOSAPI voidhashmap_put (hashmap_t *map, uintn key, void *value)
 
MOSAPI voidhashmap_get (hashmap_t *map, uintn key)
 
MOSAPI voidhashmap_remove (hashmap_t *map, uintn key)
 
MOSAPI void hashmap_foreach (hashmap_t *map, hashmap_foreach_func_t func, void *data)
 

Detailed Description

A simple hashmap.

Typedef Documentation

◆ hashmap_hash_t

typedef hash_t(* hashmap_hash_t) (const uintn key)

Definition at line 16 of file hashmap.h.

◆ hashmap_key_compare_t

typedef int(* hashmap_key_compare_t) (const uintn key1, const uintn key2)

A hashmap hash function prototype.

Definition at line 17 of file hashmap.h.

◆ hashmap_foreach_func_t

typedef bool(* hashmap_foreach_func_t) (const uintn key, void *value, void *data)

A hashmap key comparison function prototype.

Definition at line 18 of file hashmap.h.

◆ hashmap_entry_t

typedef struct hashmap_entry hashmap_entry_t

A hashmap foreach callback function prototype.

Definition at line 20 of file hashmap.h.

Function Documentation

◆ hashmap_init()

MOSAPI void hashmap_init ( hashmap_t * map,
size_t capacity,
hashmap_hash_t hash_func,
hashmap_key_compare_t compare_func )

Definition at line 24 of file hashmap.c.

Referenced by inode_init(), ipc_init(), mountpoint_map_init(), and tasks_init().

◆ hashmap_deinit()

MOSAPI void hashmap_deinit ( hashmap_t * map)

Deinitialize a hashmap.

Precondition
The hashmap must be initialized.
The hashmap should be empty, otherwise the entries will be leaked.
Warning
This function does not free the hashmap itself, nor does it free the keys or values, but only the internal data structures.
Parameters
mapThe hashmap to deinitialize.

Definition at line 49 of file hashmap.c.

Referenced by __mos_test_wrapped_test_hashmap_foreach_function(), __mos_test_wrapped_test_hashmap_get_function(), __mos_test_wrapped_test_hashmap_init_simple_macro(), __mos_test_wrapped_test_hashmap_put_multiple(), __mos_test_wrapped_test_hashmap_put_overflow(), __mos_test_wrapped_test_hashmap_put_single(), and __mos_test_wrapped_test_hashmap_remove_function().

◆ hashmap_put()

◆ hashmap_get()

◆ hashmap_remove()

◆ hashmap_foreach()