diff options
author | Tom Willemse | 2021-09-18 11:10:11 -0700 |
---|---|---|
committer | Tom Willemse | 2021-09-18 11:10:11 -0700 |
commit | aa41f26a26fcff212ecc55750a4806d83a6cf5dc (patch) | |
tree | 77238d0c1e8dfb90a04c2528b20484ddfab8e29c /clox/src/table.h | |
parent | 8ec913756107cc8e6aee965d0dc080039d4995ad (diff) | |
download | crafting-interpreters-aa41f26a26fcff212ecc55750a4806d83a6cf5dc.tar.gz crafting-interpreters-aa41f26a26fcff212ecc55750a4806d83a6cf5dc.zip |
Chapter 19.4 - 19.5
Diffstat (limited to 'clox/src/table.h')
-rw-r--r-- | clox/src/table.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/clox/src/table.h b/clox/src/table.h new file mode 100644 index 0000000..b4c3271 --- /dev/null +++ b/clox/src/table.h @@ -0,0 +1,27 @@ +#ifndef TABLE_H +#define TABLE_H + +#include "common.h" +#include "value.h" + +typedef struct { + ObjString *key; + Value value; +} Entry; + +typedef struct { + int count; + int capacity; + Entry *entries; +} Table; + +void initTable(Table *table); +void freeTable(Table *table); +bool tableGet(Table *table, ObjString *key, Value *value); +bool tableSet(Table *table, ObjString *key, Value value); +bool tableDelete(Table *table, ObjString *key); +void tableAddAll(Table *from, Table *to); +ObjString *tableFindString(Table *talbe, const char *chars, int length, + uint32_t hash); + +#endif |