Implemented and tested literal dictionary

This commit is contained in:
2022-08-08 07:58:30 +01:00
parent 3fb952e3c2
commit 6f4bfc0e10
8 changed files with 343 additions and 7 deletions

View File

@@ -0,0 +1,25 @@
#pragma once
#include "common.h"
#include "literal.h"
//TODO: benchmark this
#define DICTIONARY_MAX_LOAD 0.75
typedef struct _entry {
Literal key;
Literal value;
} _entry;
typedef struct LiteralDictionary {
_entry* entries;
int capacity;
int count;
} LiteralDictionary;
void initLiteralDictionary(LiteralDictionary* dictionary);
void freeLiteralDictionary(LiteralDictionary* dictionary);
void setLiteralDictionary(LiteralDictionary* dictionary, Literal key, Literal value);
Literal getLiteralDictionary(LiteralDictionary* dictionary, Literal key);
void removeLiteralDictionary(LiteralDictionary* dictionary, Literal key);