PatchworkOS  966e257
A non-POSIX operating system.
Loading...
Searching...
No Matches
map.c File Reference
#include <kernel/utils/map.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/math.h>
Include dependency graph for map.c:

Go to the source code of this file.

Functions

static bool is_power_of_two (uint64_t n)
 
static uint64_t next_power_of_two (uint64_t n)
 
uint64_t hash_object (const void *object, uint64_t length)
 Hash a object.
 
bool map_key_is_equal (const map_key_t *a, const map_key_t *b)
 
void map_entry_init (map_entry_t *entry)
 Initialize a map entry.
 
static uint64_t map_find_slot (const map_t *map, const map_key_t *key, bool forInsertion)
 
static uint64_t map_resize (map_t *map, uint64_t newCapacity)
 
void map_init (map_t *map)
 Initialize a map.
 
void map_deinit (map_t *map)
 Deinitialize a map.
 
static uint64_t map_resize_check (map_t *map)
 
uint64_t map_insert (map_t *map, const map_key_t *key, map_entry_t *entry)
 Insert a key-value pair into the map.
 
uint64_t map_replace (map_t *map, const map_key_t *key, map_entry_t *entry)
 Replace a key-value pair in the map.
 
map_entry_tmap_get (map_t *map, const map_key_t *key)
 Get a value from the map by key.
 
static void map_remove_index (map_t *map, uint64_t index)
 
map_entry_tmap_get_and_remove (map_t *map, const map_key_t *key)
 Get and remove a key-value pair from the map.
 
void map_remove (map_t *map, map_entry_t *entry)
 Remove a entry from the map.
 
void map_remove_key (map_t *map, const map_key_t *key)
 Remove a key-value pair from the map by key.
 
uint64_t map_size (const map_t *map)
 Get the number of entries in the map.
 
uint64_t map_capacity (const map_t *map)
 Get the capacity of the map.
 
bool map_is_empty (const map_t *map)
 Check if the map is empty.
 
bool map_contains (map_t *map, const map_key_t *key)
 Check if the map contains a key.
 
void map_clear (map_t *map)
 Clear all entries from the map.
 
uint64_t map_reserve (map_t *map, uint64_t minCapacity)
 Reserve space in the map for at least minCapacity entries.
 

Function Documentation

◆ is_power_of_two()

static bool is_power_of_two ( uint64_t  n)
static

Definition at line 8 of file map.c.

Here is the caller graph for this function:

◆ next_power_of_two()

static uint64_t next_power_of_two ( uint64_t  n)
static

Definition at line 13 of file map.c.

Here is the caller graph for this function:

◆ map_key_is_equal()

bool map_key_is_equal ( const map_key_t a,
const map_key_t b 
)

Definition at line 56 of file map.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ map_find_slot()

static uint64_t map_find_slot ( const map_t map,
const map_key_t key,
bool  forInsertion 
)
static

Definition at line 79 of file map.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ map_resize()

static uint64_t map_resize ( map_t map,
uint64_t  newCapacity 
)
static

Definition at line 121 of file map.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ map_resize_check()

static uint64_t map_resize_check ( map_t map)
static

Definition at line 193 of file map.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ map_remove_index()

static void map_remove_index ( map_t map,
uint64_t  index 
)
static

Definition at line 309 of file map.c.

Here is the call graph for this function:
Here is the caller graph for this function: