gwion-util
utilities for the Gwion project
Loading...
Searching...
No Matches
map.h
Go to the documentation of this file.
1
4#pragma once
5
6typedef struct Map_ {
8} * Map;
9
10#define VKEY(v, i) (v)->ptr[OFFSET + (i)*2]
11#define VVAL(v, i) (v)->ptr[OFFSET + (i)*2 + 1]
12
13ANEW extern Map new_map(MemPool);
14extern void map_init(const Map);
15extern ANN vtype map_get(const Map, const vtype);
16extern ANN m_int map_index(const Map, const vtype);
17
18ANN static inline vtype map_at(const Map map, const vtype index) {
19 return VVAL(map, index);
20}
21
22ANN static inline vtype map_key(const Map map, const vtype index) {
23 return VPTR(map, index*2);
24}
25
26extern ANN void map_set(const Map, const vtype, const vtype);
27extern ANN void map_remove(const Map, const vtype);
28extern ANN void map_commit(const __restrict__ Map, __restrict__ const Map);
29extern ANN void map_clear(const Map);
30extern ANN void free_map(MemPool p, const Map);
31extern ANN void map_release(const Map);
32ANN static inline vtype map_size(const Map map) { return VLEN(map); }
#define VLEN(v)
Definition container.h:8
uintptr_t vtype
Definition container.h:12
#define VPTR(v, i)
Definition container.h:10
#define ANN
Definition defs.h:18
#define ANEW
Definition defs.h:21
intptr_t m_int
Definition gwcommon.h:11
static ANN vtype map_size(const Map map)
Definition map.h:32
ANN void map_set(const Map, const vtype, const vtype)
Definition map.c:32
void map_init(const Map)
Definition map.c:9
#define VVAL(v, i)
Definition map.h:11
ANN m_int map_index(const Map, const vtype)
Definition map.c:26
static ANN vtype map_key(const Map map, const vtype index)
Definition map.h:22
ANEW Map new_map(MemPool)
Definition map.c:14
ANN void free_map(MemPool p, const Map)
Definition map.c:63
ANN void map_commit(const __restrict__ Map, __restrict__ const Map)
ANN vtype map_get(const Map, const vtype)
Definition map.c:20
ANN void map_clear(const Map)
Definition map.c:3
ANN void map_release(const Map)
Definition map.c:61
ANN void map_remove(const Map, const vtype)
Definition map.c:44
struct Map_ * Map
static ANN vtype map_at(const Map map, const vtype index)
Definition map.h:18
struct MemPool_ * MemPool
Definition map.h:6
vtype * ptr
Definition map.h:7