mirror of
https://github.com/CPunch/Cosmo.git
synced 2024-11-06 00:30:05 +00:00
cpunch
66d77bc54b
This sets up room for the '__equal' metamethod to be added - cosmoO_equals now requires the state to be passed - cosmoV_equals now requires the state to be passed - cosmoT_get now requires the state to be passed
35 lines
999 B
C
35 lines
999 B
C
#ifndef CTABLE_H
|
|
#define CTABLE_H
|
|
|
|
/* TODO: rewrite this table implementation. compared to other languages (including python!) this table is verrryyyy slow */
|
|
|
|
#include "cosmo.h"
|
|
#include "cvalue.h"
|
|
|
|
typedef struct CTableEntry {
|
|
CValue key;
|
|
CValue val;
|
|
} CTableEntry;
|
|
|
|
typedef struct CTable {
|
|
int count;
|
|
int capacityMask; // +1 to get the capacity
|
|
int tombstones;
|
|
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 int cosmoT_count(CTable *tbl);
|
|
|
|
bool cosmoT_checkShrink(CState *state, CTable *tbl);
|
|
|
|
CObjString *cosmoT_lookupString(CTable *tbl, const char *str, int length, uint32_t hash);
|
|
CValue *cosmoT_insert(CState *state, CTable *tbl, CValue key);
|
|
bool cosmoT_get(CState *state, CTable *tbl, CValue key, CValue *val);
|
|
bool cosmoT_remove(CState *state, CTable *tbl, CValue key);
|
|
|
|
void cosmoT_printTable(CTable *tbl, const char *name);
|
|
|
|
#endif
|