Subastra
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions
map.h File Reference
#include <string.h>
#include "defs.h"
#include "memory.h"
Include dependency graph for map.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  map_bucket_t
 
struct  map_t
 

Macros

#define map_insert_ty(ty, map, key, data)   map_insert(map, key, data, sizeof(ty))
 
#define map_get_ty(ty, map, key)   (ty *)map_get(map, key)
 Returns a typed pointer to a member at key key. Returns NULL if the key is not present.
 

Typedefs

typedef u32 map_key_t
 
typedef map_key_t(* hash_function_f) (void *, sz)
 
typedef struct map_bucket_t map_bucket_t
 
typedef struct map_t map_t
 

Functions

static bool map_should_grow (const map_t *map)
 Calculates if the map reached its MAP_LOAD_FACTOR. O(1)
 
static sz map_calculate_next_capacity (const map_t *map)
 Calculates the next capacity for the map. May return the same capacity if the MAP_LOAD_FACTOR is not reached. O(1*)
 
static void map_insert (map_t *map, map_key_t key, void *data, sz size)
 

Macro Definition Documentation

◆ map_get_ty

#define map_get_ty (   ty,
  map,
  key 
)    (ty *)map_get(map, key)

Returns a typed pointer to a member at key key. Returns NULL if the key is not present.

◆ map_insert_ty

#define map_insert_ty (   ty,
  map,
  key,
  data 
)    map_insert(map, key, data, sizeof(ty))

Typedef Documentation

◆ hash_function_f

typedef map_key_t(* hash_function_f) (void *, sz)

◆ map_bucket_t

typedef struct map_bucket_t map_bucket_t

◆ map_key_t

typedef u32 map_key_t

◆ map_t

typedef struct map_t map_t

Function Documentation

◆ map_calculate_next_capacity()

static sz map_calculate_next_capacity ( const map_t map)
static

Calculates the next capacity for the map. May return the same capacity if the MAP_LOAD_FACTOR is not reached. O(1*)

◆ map_insert()

static void map_insert ( map_t map,
map_key_t  key,
void *  data,
sz  size 
)
static

◆ map_should_grow()

static bool map_should_grow ( const map_t map)
static

Calculates if the map reached its MAP_LOAD_FACTOR. O(1)