summaryrefslogtreecommitdiff
path: root/ht.h
blob: 36a1d2a58da6d848f0a845b04cf9cd861303e7e1 (plain)
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
#ifndef _ht_h
#define _ht_h

typedef struct _ht Ht;
typedef struct _state State;

#include "val.h"

typedef struct {
	ObjString *k;
	Val v;
} HtEntry;

typedef struct _ht {
	size_t len;
	size_t cap;
	HtEntry *d;
} Ht;

uint32_t hash_string(char *s, size_t len);

Ht ht_new();
void ht_put(State *S, Ht *h, ObjString *k, Val v);
Val ht_get(State *S, Ht *h, ObjString *k);
ObjString *ht_findstring(State *S, Ht *h, char *s, size_t len, uint32_t hash);

#endif