Tinyhash
This is a library containing multiple C implementations of hashmap.
Loading...
Searching...
No Matches
table.h
Go to the documentation of this file.
1#ifndef __TINYHASH_OA_TABLE_H__
2#define __TINYHASH_OA_TABLE_H__
3
4#include <stdbool.h>
5#include <stdint.h>
6#include <stdlib.h>
7
9#include "../common/types.h"
10#include "entry.h"
11
16#define TH_OA_LOAD_FACTOR 0.75
17
18typedef struct {
19 uint32_t count;
20 uint32_t capacity;
23
30
37
48 size_t data_size);
49
61bool th_oa_table_put(th_generic_table_t table, th_any_t data, size_t data_size,
62 th_any_t value);
63
70
82 size_t data_size);
83
95 bool is_begin);
96
103int th_oa_table_len(th_generic_table_t generic_table);
104
105#endif
void th_oa_table_init(th_oa_table_t *table)
Initialize open adressing table values.
Definition table.c:14
bool th_oa_table_put(th_generic_table_t table, th_any_t data, size_t data_size, th_any_t value)
Insert a value within an open addressing table. Return true on success.
Definition table.c:189
bool th_oa_table_delete(th_generic_table_t table, th_any_t data, size_t data_size)
Delete a key value pair in an open addressing table. Return true on success.
Definition table.c:197
th_iterator_t * th_oa_iterator_begin(th_generic_table_t generic_table, bool is_begin)
Return a new iterator.
Definition table.c:272
th_any_t th_oa_table_get(th_generic_table_t table, th_any_t data, size_t data_size)
Get a value from an open addressing table. Return NULL if it does exist.
Definition table.c:138
void th_oa_table_free(th_generic_table_t table)
Free an open addressing table.
Definition table.c:219
int th_oa_table_len(th_generic_table_t generic_table)
Returns the table length.
Definition table.c:289
th_generic_table_t th_oa_table_create()
Return an allocated open addressing table struct.
Definition table.c:38
Represents an iterator that allow to iterate over a generic table.
Definition iterator.h:11
Represent an entry within a bucket.
Definition entry.h:15
uint32_t capacity
Definition table.h:20
th_oa_entry_t * entries
Definition table.h:21
uint32_t count
Definition table.h:19
void * th_generic_table_t
Represents any table.
Definition types.h:14
void * th_any_t
Represent any type of data.
Definition types.h:8