From aa41f26a26fcff212ecc55750a4806d83a6cf5dc Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Sat, 18 Sep 2021 11:10:11 -0700 Subject: Chapter 19.4 - 19.5 --- clox/src/table.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 clox/src/table.h (limited to 'clox/src/table.h') 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 -- cgit v1.2.3-54-g00ecf