| 49 static CxMapIterator cx_empty_map_iterator( |
49 static CxMapIterator cx_empty_map_iterator( |
| 50 const struct cx_map_s *map, |
50 const struct cx_map_s *map, |
| 51 cx_attr_unused enum cx_map_iterator_type type |
51 cx_attr_unused enum cx_map_iterator_type type |
| 52 ) { |
52 ) { |
| 53 CxMapIterator iter = {0}; |
53 CxMapIterator iter = {0}; |
| 54 iter.map.c = map; |
54 iter.map = (CxMap*) map; |
| 55 iter.base.valid = cx_empty_map_iter_valid; |
55 iter.base.valid = cx_empty_map_iter_valid; |
| 56 return iter; |
56 return iter; |
| 57 } |
57 } |
| 58 |
58 |
| 59 static struct cx_map_class_s cx_empty_map_class = { |
59 static struct cx_map_class_s cx_empty_map_class = { |
| 82 |
82 |
| 83 CxMap *const cxEmptyMap = &cx_empty_map; |
83 CxMap *const cxEmptyMap = &cx_empty_map; |
| 84 |
84 |
| 85 // </editor-fold> |
85 // </editor-fold> |
| 86 |
86 |
| 87 CxMapIterator cxMapMutIteratorValues(CxMap *map) { |
87 void cxMapClear(CxMap *map) { |
| 88 if (map == NULL) map = cxEmptyMap; |
88 map->cl->clear(map); |
| 89 CxMapIterator it = map->cl->iterator(map, CX_MAP_ITERATOR_VALUES); |
|
| 90 it.base.mutating = true; |
|
| 91 return it; |
|
| 92 } |
89 } |
| 93 |
90 |
| 94 CxMapIterator cxMapMutIteratorKeys(CxMap *map) { |
91 size_t cxMapSize(const CxMap *map) { |
| 95 if (map == NULL) map = cxEmptyMap; |
92 return map->collection.size; |
| 96 CxMapIterator it = map->cl->iterator(map, CX_MAP_ITERATOR_KEYS); |
|
| 97 it.base.mutating = true; |
|
| 98 return it; |
|
| 99 } |
93 } |
| 100 |
94 |
| 101 CxMapIterator cxMapMutIterator(CxMap *map) { |
95 CxMapIterator cxMapIteratorValues(const CxMap *map) { |
| 102 if (map == NULL) map = cxEmptyMap; |
96 if (map == NULL) map = cxEmptyMap; |
| 103 CxMapIterator it = map->cl->iterator(map, CX_MAP_ITERATOR_PAIRS); |
97 return map->cl->iterator(map, CX_MAP_ITERATOR_VALUES); |
| 104 it.base.mutating = true; |
98 } |
| 105 return it; |
99 |
| |
100 CxMapIterator cxMapIteratorKeys(const CxMap *map) { |
| |
101 if (map == NULL) map = cxEmptyMap; |
| |
102 return map->cl->iterator(map, CX_MAP_ITERATOR_KEYS); |
| |
103 } |
| |
104 |
| |
105 CxMapIterator cxMapIterator(const CxMap *map) { |
| |
106 if (map == NULL) map = cxEmptyMap; |
| |
107 return map->cl->iterator(map, CX_MAP_ITERATOR_PAIRS); |
| |
108 } |
| |
109 |
| |
110 int cx_map_put(CxMap *map, CxHashKey key, void *value) { |
| |
111 return map->cl->put(map, key, value) == NULL; |
| |
112 } |
| |
113 |
| |
114 void *cx_map_emplace(CxMap *map, CxHashKey key) { |
| |
115 return map->cl->put(map, key, NULL); |
| |
116 } |
| |
117 |
| |
118 void *cx_map_get(const CxMap *map, CxHashKey key) { |
| |
119 return map->cl->get(map, key); |
| |
120 } |
| |
121 |
| |
122 int cx_map_remove(CxMap *map, CxHashKey key, void *targetbuf) { |
| |
123 return map->cl->remove(map, key, targetbuf); |
| 106 } |
124 } |
| 107 |
125 |
| 108 void cxMapFree(CxMap *map) { |
126 void cxMapFree(CxMap *map) { |
| 109 if (map == NULL) return; |
127 if (map == NULL) return; |
| 110 map->cl->deallocate(map); |
128 map->cl->deallocate(map); |