ucx/map.c

branch
ucx-3.1
changeset 816
839fefbdedc7
parent 750
4d7a2238c5ac
equal deleted inserted replaced
815:1f40ca07ae1b 816:839fefbdedc7
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.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 = {
64 NULL, 64 NULL,
65 cx_empty_map_iterator 65 cx_empty_map_iterator
66 }; 66 };
67 67
68 CxMap cx_empty_map = { 68 CxMap cx_empty_map = {
69 NULL, 69 {
70 NULL, 70 NULL,
71 0, 71 NULL,
72 0, 72 0,
73 NULL, 73 0,
74 NULL, 74 NULL,
75 NULL, 75 NULL,
76 false, 76 NULL,
77 false
78 },
77 &cx_empty_map_class 79 &cx_empty_map_class
78 }; 80 };
79 81
80 CxMap *const cxEmptyMap = &cx_empty_map; 82 CxMap *const cxEmptyMap = &cx_empty_map;
81 83
82 // </editor-fold> 84 // </editor-fold>
83 85
84 CxMutIterator cxMapMutIteratorValues(CxMap *map) { 86 CxIterator cxMapMutIteratorValues(CxMap *map) {
85 CxIterator it = map->cl->iterator(map, CX_MAP_ITERATOR_VALUES); 87 CxIterator it = map->cl->iterator(map, CX_MAP_ITERATOR_VALUES);
86 it.base.mutating = true; 88 it.base.mutating = true;
87 89 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 } 90 }
93 91
94 CxMutIterator cxMapMutIteratorKeys(CxMap *map) { 92 CxIterator cxMapMutIteratorKeys(CxMap *map) {
95 CxIterator it = map->cl->iterator(map, CX_MAP_ITERATOR_KEYS); 93 CxIterator it = map->cl->iterator(map, CX_MAP_ITERATOR_KEYS);
96 it.base.mutating = true; 94 it.base.mutating = true;
97 95 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 } 96 }
103 97
104 CxMutIterator cxMapMutIterator(CxMap *map) { 98 CxIterator cxMapMutIterator(CxMap *map) {
105 CxIterator it = map->cl->iterator(map, CX_MAP_ITERATOR_PAIRS); 99 CxIterator it = map->cl->iterator(map, CX_MAP_ITERATOR_PAIRS);
106 it.base.mutating = true; 100 it.base.mutating = true;
107 101 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 } 102 }

mercurial