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 #include "cx/map.h"
30 #include <string.h>
31
32
33
34 static void cx_empty_map_noop(__attribute__((__unused__)) CxMap *map) {
35
36 }
37
38 static void *cx_empty_map_get(
39 __attribute__((__unused__)) CxMap
const *map,
40 __attribute__((__unused__)) CxHashKey key
41 ) {
42 return NULL;
43 }
44
45 static bool cx_empty_map_iter_valid(__attribute__((__unused__))
void const *iter) {
46 return false;
47 }
48
49 static CxIterator cx_empty_map_iterator(
50 struct cx_map_s
const *map,
51 __attribute__((__unused__))
enum cx_map_iterator_type type
52 ) {
53 CxIterator iter = {
0};
54 iter.src_handle.c = map;
55 iter.base.valid = cx_empty_map_iter_valid;
56 return iter;
57 }
58
59 static struct cx_map_class_s cx_empty_map_class = {
60 cx_empty_map_noop,
61 cx_empty_map_noop,
62 NULL,
63 cx_empty_map_get,
64 NULL,
65 cx_empty_map_iterator
66 };
67
68 CxMap cx_empty_map = {
69 {
70 NULL,
71 NULL,
72 0,
73 0,
74 NULL,
75 NULL,
76 NULL,
77 false
78 },
79 &cx_empty_map_class
80 };
81
82 CxMap *
const cxEmptyMap = &cx_empty_map;
83
84
85
86 CxIterator cxMapMutIteratorValues(CxMap *map) {
87 CxIterator it = map->cl->iterator(map,
CX_MAP_ITERATOR_VALUES);
88 it.base.mutating = true;
89 return it;
90 }
91
92 CxIterator cxMapMutIteratorKeys(CxMap *map) {
93 CxIterator it = map->cl->iterator(map,
CX_MAP_ITERATOR_KEYS);
94 it.base.mutating = true;
95 return it;
96 }
97
98 CxIterator cxMapMutIterator(CxMap *map) {
99 CxIterator it = map->cl->iterator(map,
CX_MAP_ITERATOR_PAIRS);
100 it.base.mutating = true;
101 return it;
102 }
103