Banjo API 0.0.1
Multi-purpose C99 API
Loading...
Searching...
No Matches
htable.h
Go to the documentation of this file.
1
5
15#pragma once
16
17#include <banjo/api.h>
18#include <banjo/array.h>
19#include <banjo/memory.h>
20
22typedef uint32_t (*bj_hash_fn)(
23 const void* p_data, size_t size
24);
25
28typedef struct bj_htable_t bj_htable;
29
38 size_t bytes_key,
39 size_t bytes_value
40);
41
49#define bj_htable_new_t(K, V) bj_htable_new(sizeof(K), sizeof(V))
50
56BANJO_EXPORT void bj_htable_del(
57 bj_htable* p_table
58);
59
80BANJO_EXPORT void* bj_htable_set(
81 bj_htable* table,
82 void* p_key,
83 void* p_value
84);
85
96BANJO_EXPORT void* bj_htable_get(
97 const bj_htable* table,
98 const void* p_key,
99 void* p_default
100);
101
108BANJO_EXPORT size_t bj_htable_len(
109 const bj_htable* table
110);
111
General-purpose definitions for Banjo API.
Header file for Array container type.
struct bj_htable_t bj_htable
Typedef for the bj_htable_t struct.
Definition htable.h:28
void * bj_htable_set(bj_htable *table, void *p_key, void *p_value)
Inserts a value into the hash table.
bj_htable * bj_htable_new(size_t bytes_key, size_t bytes_value)
Creates a new bj_htable with the specified sizes for keys and values.
size_t bj_htable_len(const bj_htable *table)
Returns the number of elements in the table.
uint32_t(* bj_hash_fn)(const void *p_data, size_t size)
Function type for hashing keys.
Definition htable.h:22
void * bj_htable_get(const bj_htable *table, const void *p_key, void *p_default)
Returns the value associated with p_key, if it exists.
void bj_htable_del(bj_htable *p_table)
Deletes a bj_htable object and releases associated memory.
All memory-related functions, including custom allocators.