-
Notifications
You must be signed in to change notification settings - Fork 0
/
table.h
50 lines (37 loc) · 993 Bytes
/
table.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
41
42
43
44
45
46
47
48
49
50
#ifndef TABLE_H
#define TABLE_H
#include "base_type.h"
#define GET_VALUE(p) (*(Dollar*)((p)+size1))
/**
* hashtable with linear probing
*
* element structure:
* positionHintB: freeJointSize
* cost: sizeof(Dollar)
*/
typedef struct _CostTable{
int size1;
int size2;
int size2_;
float limit;
gpointer data;
} CostTable;
CostTable *table_init(CostTable *f,int size1,int size2,float limit);
/**
* return EMPTY_VALUE if no entry found
* corresponding value otherwise
*/
Dollar table_peek(const CostTable *table,gconstpointer element);
/**
* IMPORTANT: value is not updated if key already exist
* return table_peek(element) before insert
*/
Dollar table_insert(CostTable *table,gconstpointer element, Dollar cost);
/**
* size1 is size of element
* size2 is number of entries in hashtable
*/
int table_hash(gconstpointer element,int size1,int size2);
void table_free(CostTable *table);
void table_print(GLogLevelFlags flags,CostTable *table);
#endif