summaryrefslogtreecommitdiff
path: root/ht.h
blob: 656df736c9f233d1ae5a921a437eec5985b36b27 (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
#ifndef _ht_h
#define _ht_h

typedef struct _ht Ht;

#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