-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathltable.h
More file actions
44 lines (33 loc) · 1.19 KB
/
ltable.h
File metadata and controls
44 lines (33 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef LTABLE_H
#define LTABLE_H
#include <stdbool.h>
#define LTABLE_SEED
#define LTABLE_KEYNUM 1
#define LTABLE_KEYINT 2
#define LTABLE_KEYSTR 3
#define LTABLE_KEYOBJ 4
#define ltable_keytype(key) ((key)->type)
#define ltable_keyval(key) ((key)->v)
struct ltable_key {
int type;
union {
double f;
long int i;
const void * p;
const char* s;
} v;
};
struct ltable;
struct ltable* ltable_create(size_t vmemsz, unsigned int seed);
void ltable_release(struct ltable *);
void ltable_resize(struct ltable *t, int nasize, int nhsize);
void* ltable_next(struct ltable *t, unsigned int *ip, struct ltable_key *key);
void* ltable_get(struct ltable* t, const struct ltable_key* key);
void* ltable_set(struct ltable* t, const struct ltable_key* key);
void* ltable_getn(struct ltable* t, int i);
void ltable_del(struct ltable* t, const struct ltable_key* key);
struct ltable_key* ltable_numkey(struct ltable_key *key, double k);
struct ltable_key* ltable_strkey(struct ltable_key *key, const char* k);
struct ltable_key* ltable_intkey(struct ltable_key *key, long int k);
struct ltable_key* ltable_objkey(struct ltable_key *key, const void *p);
#endif