-
Notifications
You must be signed in to change notification settings - Fork 5
/
cons.h
55 lines (46 loc) · 1.66 KB
/
cons.h
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
45
46
47
48
49
50
51
52
53
54
55
#pragma once
#include "cthing.h"
#include "mem/mpool.h"
CT_BEGIN_DECLS
typedef struct CT_Cons CT_Cons;
typedef struct CT_ConsD CT_ConsD;
struct CT_Cons {
void* value;
CT_Cons* next;
};
struct CT_ConsD {
void* value;
CT_ConsD* next;
CT_ConsD* prev;
};
typedef void (*CT_ConsVisitor)(CT_Cons*, void*);
CT_Cons* ct_cons(void* val, CT_Cons* head, CT_MPool* mpool);
CT_Cons* ct_cons_append(void* val, CT_Cons* tail, CT_MPool* pool);
CT_Cons* ct_cons_get_tail(CT_Cons* cell);
void ct_cons_free(CT_Cons* cell,
CT_MPool* pool,
void (*freeVal)(void*, void*),
void* state);
void ct_cons_free_all(CT_Cons* cell,
CT_MPool* pool,
void (*freeVal)(void*, void*),
void* state);
void* ct_cons_iterate(CT_Cons* cell, CT_ConsVisitor visit, void* state);
void* ct_cons_iterate_n(CT_Cons* cell,
CT_ConsVisitor visit,
void* state,
size_t num);
CT_Cons* ct_cons_from_array(void* values,
size_t num,
size_t stride,
CT_Cons* head,
CT_MPool* mpool);
CT_Cons* ct_cons_from_parray(void** values,
size_t num,
CT_Cons* head,
CT_MPool* mpool);
CT_Cons* ct_cons_concat_imm(CT_Cons* head, CT_Cons* rest);
CT_Cons* ct_cons_concat(CT_Cons* head, CT_Cons* rest, CT_MPool* mpool);
CT_Cons* ct_cons_take(CT_Cons* head, size_t num, CT_MPool* pool);
CT_ConsD* ct_consd(void* x, CT_ConsD* head, CT_MPool* mpool);
CT_END_DECLS