-
Notifications
You must be signed in to change notification settings - Fork 1
/
table.h
34 lines (28 loc) · 956 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
#ifndef clox_table_h
#define clox_table_h
#include "value.h"
typedef struct {
Value key;
Value value;
} Entry;
typedef struct {
int16_t count;
int16_t capacity;
Entry* entries;
} Table;
void initTable(Table* table);
void freeTable(Table* table);
bool tableGet(Table* table, Value key, Value* value);
bool tableSet(Table* table, Value key, Value value);
bool tableDelete(Table* table, Value key);
void tableAddAll(Table* from, Table* to);
ObjString* tableFindString(Table* table, const char* chars, int length, uint32_t hash);
void tableRemoveWhite(Table* table);
void tableShrink(Table* table);
void markTable(Table* table);
int firstIterator(Table* table);
void nextIterator(ObjIterator* iter);
bool isValidIterator(ObjIterator* iter);
Value getIterator(ObjIterator* iter, bool wantKey);
void setIterator(ObjIterator* iter, Value value);
#endif