Zephyr Project API  3.4.0
A Scalable Open Source RTOS
hash_map.h File Reference

Hashmap (Hash Table) API. More...

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <zephyr/kernel.h>
#include <zephyr/sys/hash_map_api.h>
#include <zephyr/sys/hash_map_cxx.h>
#include <zephyr/sys/hash_map_oa_lp.h>
#include <zephyr/sys/hash_map_sc.h>

Go to the source code of this file.

Data Structures

struct  sys_hashmap
 Generic Hashmap. More...
 
#define SYS_HASHMAP_DEFINE_ADVANCED(_name, _api, _config_type, _data_type, _hash_func, _alloc_func, ...)
 Declare a Hashmap (advanced) More...
 
#define SYS_HASHMAP_DEFINE_STATIC_ADVANCED(_name, _api, _config_type, _data_type, _hash_func, _alloc_func, ...)
 Declare a Hashmap (advanced) More...
 
#define SYS_HASHMAP_DEFINE(_name)   SYS_HASHMAP_DEFAULT_DEFINE(_name)
 Declare a Hashmap. More...
 
#define SYS_HASHMAP_DEFINE_STATIC(_name)   SYS_HASHMAP_DEFAULT_DEFINE_STATIC(_name)
 Declare a Hashmap statically. More...
 
#define SYS_HASHMAP_DEFAULT_ALLOCATOR   sys_hashmap_default_allocator
 
#define SYS_HASHMAP_DEFAULT_LOAD_FACTOR   75
 The default Hashmap load factor (in hundredths) More...
 
static void * sys_hashmap_default_allocator (void *ptr, size_t size)
 
static void sys_hashmap_foreach (const struct sys_hashmap *map, sys_hashmap_callback_t cb, void *cookie)
 Iterate over all values contained in a sys_hashmap. More...
 
static void sys_hashmap_clear (struct sys_hashmap *map, sys_hashmap_callback_t cb, void *cookie)
 Clear all entries contained in a sys_hashmap. More...
 
static int sys_hashmap_insert (struct sys_hashmap *map, uint64_t key, uint64_t value, uint64_t *old_value)
 Insert a new entry into a sys_hashmap. More...
 
static bool sys_hashmap_remove (struct sys_hashmap *map, uint64_t key, uint64_t *value)
 Remove an entry from a sys_hashmap. More...
 
static bool sys_hashmap_get (const struct sys_hashmap *map, uint64_t key, uint64_t *value)
 Get a value from a sys_hashmap. More...
 
static bool sys_hashmap_contains_key (const struct sys_hashmap *map, uint64_t key)
 Check if map contains a value associated with key. More...
 
static size_t sys_hashmap_size (const struct sys_hashmap *map)
 Query the number of entries contained within map. More...
 
static bool sys_hashmap_is_empty (const struct sys_hashmap *map)
 Check if map is empty. More...
 
static uint8_t sys_hashmap_load_factor (const struct sys_hashmap *map)
 Query the load factor of map. More...
 
static size_t sys_hashmap_num_buckets (const struct sys_hashmap *map)
 Query the number of buckets used in map. More...
 
static bool sys_hashmap_should_rehash (const struct sys_hashmap *map, bool grow, size_t num_reserved, size_t *new_num_buckets)
 Decide whether the Hashmap should be resized. More...
 

Detailed Description

Hashmap (Hash Table) API.

Hashmaps (a.k.a Hash Tables) sacrifice space for speed. All operations on a Hashmap (insert, delete, search) are O(1) complexity (on average).