-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtranstable.h
40 lines (33 loc) · 851 Bytes
/
transtable.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef c4_transtable_h
#define c4_transtable_h
#include <stdint.h>
typedef struct entry {
uint_fast64_t key;
uint_fast8_t val;
} entry;
/*
* Assigns an index to a key-value pair through a simple modulus hash.
* key: key to hash
* table: table to hash with
*/
unsigned int transtable_index(uint_fast64_t key, entry *table);
/*
* Stores an 8-bit value for agiven 56-bit key
* key: 56-bit key
* value: 8-bit non-null value
* table: table to insert into
*/
void transtable_put(uint_fast64_t key, uint_fast8_t val, entry **table);
/*
* Gets an 8-bit value with a 56-bit key
* key: 56-bit key
* table: table to get from
* return: value if present, otherwise 0
*/
uint_fast8_t transtable_get(uint_fast64_t key, entry *table);
/*
* Fills the table with zeroes
* table: table to erase
*/
void transtable_clear(entry **table);
#endif