2020-10-28 05:16:30 +00:00
|
|
|
#ifndef CTABLE_H
|
|
|
|
#define CTABLE_H
|
|
|
|
|
|
|
|
#include "cosmo.h"
|
|
|
|
#include "cvalue.h"
|
|
|
|
|
|
|
|
typedef struct CTableEntry {
|
|
|
|
CValue key;
|
|
|
|
CValue val;
|
|
|
|
} CTableEntry;
|
|
|
|
|
|
|
|
typedef struct CTable {
|
|
|
|
int count;
|
|
|
|
int capacity;
|
2020-11-17 09:10:55 +00:00
|
|
|
int tombstones;
|
2020-10-28 05:16:30 +00:00
|
|
|
CTableEntry *table;
|
|
|
|
} CTable;
|
|
|
|
|
|
|
|
COSMO_API void cosmoT_initTable(CState *state, CTable *tbl, int startCap);
|
|
|
|
COSMO_API void cosmoT_clearTable(CState *state, CTable *tbl);
|
|
|
|
COSMO_API void cosmoT_addTable(CState *state, CTable *from, CTable *to);
|
|
|
|
COSMO_API CValue *cosmoT_insert(CState *state, CTable *tbl, CValue key);
|
2020-11-30 18:32:04 +00:00
|
|
|
COSMO_API int cosmoT_count(CTable *tbl);
|
2020-10-28 05:16:30 +00:00
|
|
|
|
|
|
|
CObjString *cosmoT_lookupString(CTable *tbl, const char *str, size_t length, uint32_t hash);
|
2020-11-19 20:41:21 +00:00
|
|
|
bool cosmoT_checkShrink(CState *state, CTable *tbl);
|
2020-10-28 05:16:30 +00:00
|
|
|
bool cosmoT_get(CTable *tbl, CValue key, CValue *val);
|
2020-11-17 09:10:55 +00:00
|
|
|
bool cosmoT_remove(CState *state, CTable *tbl, CValue key);
|
2020-10-28 05:16:30 +00:00
|
|
|
|
|
|
|
void cosmoT_printTable(CTable *tbl, const char *name);
|
|
|
|
|
|
|
|
#endif
|