Data Structures Lerax  v3.0-104-ge031
Opinionated Data Structures & Algorithms
Loading...
Searching...
No Matches
hash-table.h
Go to the documentation of this file.
1
12
13#ifndef HASH_TABLE_H
14#define HASH_TABLE_H
15
16#include <stddef.h>
17#include <stdbool.h>
18#include "../list/single/list.h"
20
28typedef struct HashTable HashTable;
29
36HashTable* hash_table_create(size_t n_buckets);
37
45
53
61void hash_table_put(HashTable *ht, int key, int value);
62
69void hash_table_remove(HashTable *ht, int key);
70
78int hash_table_get(HashTable *ht, int key, bool *exists);
79
80
88
89
96
103
110
117
120
127
128#endif /* HASH_TABLE_H */
HashTable * hash_table_create(size_t n_buckets)
Create a new hash table instance.
void hash_table_remove(HashTable *ht, int key)
Remove a specific value associated with a given key.
void hash_table_free(HashTable *ht)
Free memory of hash table and its contents.
bool hash_table_empty(HashTable *ht)
Check if hash table is empty.
int hash_table_get(HashTable *ht, int key, bool *exists)
Get a value in the hash table.
void hash_table_print_items(HashTable *ht)
Print items of the hash table.
void hash_table_put(HashTable *ht, int key, int value)
Put a value associated to a key.
List * hash_table_keys(HashTable *ht)
Build a list with the hash table keys.
void hash_table_print_keys(HashTable *ht)
Print keys of the hash table.
size_t hash_table_size(HashTable *ht)
Get the number of elements in the hash table.
HashTable * hash_table_copy(HashTable *ht)
Create a hash table as copy of another.
void hash_table_print(HashTable *ht)
Print all buckets of the hash table (one list per line)
Iterator * hash_table_iterator_keys(HashTable *ht)
Iterator * hash_table_iterator_data(HashTable *ht)
struct HashTable HashTable
A basic implementation of a hash table.
Definition hash-table.h:28
struct ListNode List
A singly linked list.
Definition list.h:36
A generic iterator struct.
Definition iterator.h:13