#include <stdio.h>
#include <stdlib.h>
#include "hashmap.h"
#include "util/abort.h"
#include "util/mtrack.h"
Go to the source code of this file.
|
| void | ps_hash_map_assert_inv (const struct ps_hash_map *map) |
| | Asserts the invariants of the data structure implementation.
|
| |
| struct ps_hash_map * | ps_hash_map_new (is_equal_t is_equal, hasher_t hasher, free_fn_t free_fn) |
| | Initializes a new hash map with the given comparison and memory functions.
|
| |
| struct ps_hash_map * | _ps_hash_map_new (is_equal_t is_equal, hasher_t hasher, free_fn_t free_fn, u64 capacity) |
| |
| void | ps_hash_map_free (struct ps_hash_map *map) |
| | Destroys all data owned by the hash map.
|
| |
| void | ps_hash_map_redistribute (struct ps_hash_map **map_ptr) |
| |
| void | ps_hash_map_insert (struct ps_hash_map **map_ptr, void *key, void *value) |
| | Sets the object associated with the given key in the hash map, overwriting any existing value for that key.
|
| |
| void * | ps_hash_map_get (struct ps_hash_map *map, void *key) |
| | Gets the value associated with the given key.
|
| |
| void | ps_hash_map_remove (struct ps_hash_map *map, void *key) |
| | Removes the key-value pair associated with the given key.
|
| |
| bool | ps_hash_map_contains (struct ps_hash_map *map, void *key) |
| | Checks if the hash map contains the given key-value pair.
|
| |
| u64 | ps_hash_map_count (const struct ps_hash_map *map) |
| | Gets the number of key-value pairs in the hash map.
|
| |
◆ PS_HASH_MAP_INITIAL_CAPACITY
| #define PS_HASH_MAP_INITIAL_CAPACITY 16 |
◆ _ps_hash_map_new()
◆ ps_hash_map_assert_inv()
| void ps_hash_map_assert_inv |
( |
const struct ps_hash_map * |
map | ) |
|
Asserts the invariants of the data structure implementation.
Definition at line 12 of file hashmap.c.
◆ ps_hash_map_contains()
| bool ps_hash_map_contains |
( |
struct ps_hash_map * |
map, |
|
|
void * |
key |
|
) |
| |
Checks if the hash map contains the given key-value pair.
- Parameters
-
| map | The hash map. |
| key | The key. |
Definition at line 240 of file hashmap.c.
◆ ps_hash_map_count()
Gets the number of key-value pairs in the hash map.
- Parameters
-
- Returns
- The number of key-value pairs in the hash map.
Definition at line 244 of file hashmap.c.
◆ ps_hash_map_free()
Destroys all data owned by the hash map.
- Parameters
-
| map | The hash map to destroy. |
Definition at line 78 of file hashmap.c.
◆ ps_hash_map_get()
| void * ps_hash_map_get |
( |
struct ps_hash_map * |
map, |
|
|
void * |
key |
|
) |
| |
Gets the value associated with the given key.
- Parameters
-
| map | The hash map. |
| key | The key. |
- Returns
- The value associated with the key, or NULL if the key is not in the hash map.
Definition at line 174 of file hashmap.c.
◆ ps_hash_map_insert()
| void ps_hash_map_insert |
( |
struct ps_hash_map ** |
map_ptr, |
|
|
void * |
key, |
|
|
void * |
value |
|
) |
| |
Sets the object associated with the given key in the hash map, overwriting any existing value for that key.
Inserts a new key-value pair into the hash map.
Definition at line 119 of file hashmap.c.
◆ ps_hash_map_new()
Initializes a new hash map with the given comparison and memory functions.
Creates a new hash map with the given comparison and memory functions.
Definition at line 43 of file hashmap.c.
◆ ps_hash_map_redistribute()
| void ps_hash_map_redistribute |
( |
struct ps_hash_map ** |
map_ptr | ) |
|
◆ ps_hash_map_remove()
| void ps_hash_map_remove |
( |
struct ps_hash_map * |
map, |
|
|
void * |
key |
|
) |
| |
Removes the key-value pair associated with the given key.
- Parameters
-
| map | The hash map. |
| key | The key. |
Definition at line 193 of file hashmap.c.