Kohi Game Engine
hashtable.h
Go to the documentation of this file.
1 
12 #pragma once
13 
14 #include "defines.h"
15 
25 typedef struct hashtable {
29  void* memory;
31 
41 KAPI void hashtable_create(u64 element_size, u32 element_count, void* memory, b8 is_pointer_type, hashtable* out_hashtable);
42 
49 
59 KAPI b8 hashtable_set(hashtable* table, const char* name, void* value);
60 
70 KAPI b8 hashtable_set_ptr(hashtable* table, const char* name, void** value);
71 
81 KAPI b8 hashtable_get(hashtable* table, const char* name, void* out_value);
82 
92 KAPI b8 hashtable_get_ptr(hashtable* table, const char* name, void** out_value);
93 
103 KAPI b8 hashtable_fill(hashtable* table, void* value);
This file contains global type definitions which are used throughout the entire engine and applicatio...
#define KAPI
Import/export qualifier.
Definition: defines.h:177
unsigned int u32
Unsigned 32-bit integer.
Definition: defines.h:25
_Bool b8
8-bit boolean type
Definition: defines.h:58
unsigned long long u64
Unsigned 64-bit integer.
Definition: defines.h:28
KAPI b8 hashtable_set_ptr(hashtable *table, const char *name, void **value)
Stores a pointer as provided in value in the hashtable. Only use for tables which were created with i...
KAPI b8 hashtable_get(hashtable *table, const char *name, void *out_value)
Obtains a copy of data present in the hashtable. Only use for tables which were NOT created with is_p...
struct hashtable hashtable
Represents a simple hashtable. Members of this structure should not be modified outside the functions...
KAPI void hashtable_create(u64 element_size, u32 element_count, void *memory, b8 is_pointer_type, hashtable *out_hashtable)
Creates a hashtable and stores it in out_hashtable.
KAPI b8 hashtable_set(hashtable *table, const char *name, void *value)
Stores a copy of the data in value in the provided hashtable. Only use for tables which were NOT crea...
KAPI b8 hashtable_fill(hashtable *table, void *value)
Fills all entries in the hashtable with the given value. Useful when non-existent names should return...
KAPI b8 hashtable_get_ptr(hashtable *table, const char *name, void **out_value)
Obtains a pointer to data present in the hashtable. Only use for tables which were created with is_po...
KAPI void hashtable_destroy(hashtable *table)
Destroys the provided hashtable. Does not release memory for pointer types.
Represents a simple hashtable. Members of this structure should not be modified outside the functions...
Definition: hashtable.h:25
u32 element_count
Definition: hashtable.h:27
b8 is_pointer_type
Definition: hashtable.h:28
void * memory
Definition: hashtable.h:29
u64 element_size
Definition: hashtable.h:26