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_SC_TABLE_H__
2#define __TINYHASH_SC_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
16typedef struct {
17 uint32_t count;
18 uint32_t capacity;
21
28
35
46 size_t data_size);
47
59bool th_sc_table_put(th_generic_table_t table, th_any_t data, size_t data_size,
60 th_any_t value);
61
68
80 size_t data_size);
81
93 bool is_begin);
94
101int th_sc_table_len(th_generic_table_t generic_table);
102
103#endif
th_iterator_t * th_sc_iterator_begin(th_generic_table_t generic_table, bool is_begin)
Return a new iterator.
Definition table.c:287
bool th_sc_table_delete(th_generic_table_t table, th_any_t data, size_t data_size)
Delete a key value pair in an separate chaining table. Return true on success.
Definition table.c:191
int th_sc_table_len(th_generic_table_t generic_table)
Returns the table length.
Definition table.c:304
void th_sc_table_init(th_sc_table_t *table)
Initialize a separate chaining table.
Definition table.c:13
void th_sc_table_free(th_generic_table_t table)
Free an separate chaining table.
Definition table.c:222
th_generic_table_t th_sc_table_create()
Return an allocated separate chaining table.
Definition table.c:36
th_any_t th_sc_table_get(th_generic_table_t table, th_any_t data, size_t data_size)
Get a value from an separate chaining table. Return NULL if it does exist.
Definition table.c:133
bool th_sc_table_put(th_generic_table_t table, th_any_t data, size_t data_size, th_any_t value)
Insert a value within an separate chaining table. Return true on success.
Definition table.c:183
Represents an iterator that allow to iterate over a generic table.
Definition iterator.h:11
Represents a separate chaining entry.
Definition entry.h:15
Represent a separate chaining table.
Definition table.h:16
uint32_t capacity
Definition table.h:18
th_sc_entry_t ** entries
Definition table.h:19
uint32_t count
Definition table.h:17
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