49 static CxIterator cx_empty_map_iterator( |
49 static CxIterator cx_empty_map_iterator( |
50 struct cx_map_s const *map, |
50 struct cx_map_s const *map, |
51 __attribute__((__unused__)) enum cx_map_iterator_type type |
51 __attribute__((__unused__)) enum cx_map_iterator_type type |
52 ) { |
52 ) { |
53 CxIterator iter = {0}; |
53 CxIterator iter = {0}; |
54 iter.src_handle = map; |
54 iter.src_handle.c = map; |
55 iter.base.valid = cx_empty_map_iter_valid; |
55 iter.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 = { |
60 cx_empty_map_noop, |
60 cx_empty_map_noop, |
79 |
79 |
80 CxMap *const cxEmptyMap = &cx_empty_map; |
80 CxMap *const cxEmptyMap = &cx_empty_map; |
81 |
81 |
82 // </editor-fold> |
82 // </editor-fold> |
83 |
83 |
84 CxMutIterator cxMapMutIteratorValues(CxMap *map) { |
84 CxIterator cxMapMutIteratorValues(CxMap *map) { |
85 CxIterator it = map->cl->iterator(map, CX_MAP_ITERATOR_VALUES); |
85 CxIterator it = map->cl->iterator(map, CX_MAP_ITERATOR_VALUES); |
86 it.base.mutating = true; |
86 it.mutating = true; |
87 |
87 return it; |
88 // we know the iterators share the same memory layout |
|
89 CxMutIterator iter; |
|
90 memcpy(&iter, &it, sizeof(CxMutIterator)); |
|
91 return iter; |
|
92 } |
88 } |
93 |
89 |
94 CxMutIterator cxMapMutIteratorKeys(CxMap *map) { |
90 CxIterator cxMapMutIteratorKeys(CxMap *map) { |
95 CxIterator it = map->cl->iterator(map, CX_MAP_ITERATOR_KEYS); |
91 CxIterator it = map->cl->iterator(map, CX_MAP_ITERATOR_KEYS); |
96 it.base.mutating = true; |
92 it.mutating = true; |
97 |
93 return it; |
98 // we know the iterators share the same memory layout |
|
99 CxMutIterator iter; |
|
100 memcpy(&iter, &it, sizeof(CxMutIterator)); |
|
101 return iter; |
|
102 } |
94 } |
103 |
95 |
104 CxMutIterator cxMapMutIterator(CxMap *map) { |
96 CxIterator cxMapMutIterator(CxMap *map) { |
105 CxIterator it = map->cl->iterator(map, CX_MAP_ITERATOR_PAIRS); |
97 CxIterator it = map->cl->iterator(map, CX_MAP_ITERATOR_PAIRS); |
106 it.base.mutating = true; |
98 it.mutating = true; |
107 |
99 return it; |
108 // we know the iterators share the same memory layout |
|
109 CxMutIterator iter; |
|
110 memcpy(&iter, &it, sizeof(CxMutIterator)); |
|
111 return iter; |
|
112 } |
100 } |