src/cx/map.h

changeset 854
fe0d69d72bcd
parent 853
d4baf4dd55c3
child 855
35bcb3216c0d
equal deleted inserted replaced
853:d4baf4dd55c3 854:fe0d69d72bcd
54 /** Type for map class definitions. */ 54 /** Type for map class definitions. */
55 typedef struct cx_map_class_s cx_map_class; 55 typedef struct cx_map_class_s cx_map_class;
56 56
57 /** Structure for the UCX map. */ 57 /** Structure for the UCX map. */
58 struct cx_map_s { 58 struct cx_map_s {
59 CX_COLLECTION_MEMBERS 59 /**
60 * Base attributes.
61 */
62 CX_COLLECTION_BASE;
60 /** The map class definition. */ 63 /** The map class definition. */
61 cx_map_class *cl; 64 cx_map_class *cl;
62 }; 65 };
63 66
64 /** 67 /**
161 * @param map the map 164 * @param map the map
162 * @see cxMapStorePointers() 165 * @see cxMapStorePointers()
163 */ 166 */
164 __attribute__((__nonnull__)) 167 __attribute__((__nonnull__))
165 static inline void cxMapStoreObjects(CxMap *map) { 168 static inline void cxMapStoreObjects(CxMap *map) {
166 map->store_pointer = false; 169 map->base.store_pointer = false;
167 } 170 }
168 171
169 /** 172 /**
170 * Advises the map to only store pointers to the objects. 173 * Advises the map to only store pointers to the objects.
171 * 174 *
178 * @param map the map 181 * @param map the map
179 * @see cxMapStoreObjects() 182 * @see cxMapStoreObjects()
180 */ 183 */
181 __attribute__((__nonnull__)) 184 __attribute__((__nonnull__))
182 static inline void cxMapStorePointers(CxMap *map) { 185 static inline void cxMapStorePointers(CxMap *map) {
183 map->store_pointer = true; 186 map->base.store_pointer = true;
184 map->item_size = sizeof(void *); 187 map->base.item_size = sizeof(void *);
185 } 188 }
186 189
187 190
188 /** 191 /**
189 * Deallocates the memory of the specified map. 192 * Deallocates the memory of the specified map.
1048 __attribute__((__nonnull__, __warn_unused_result__)) 1051 __attribute__((__nonnull__, __warn_unused_result__))
1049 static inline void *cx_map_remove_and_get( 1052 static inline void *cx_map_remove_and_get(
1050 CxMap *map, 1053 CxMap *map,
1051 CxHashKey key 1054 CxHashKey key
1052 ) { 1055 ) {
1053 return map->cl->remove(map, key, !map->store_pointer); 1056 return map->cl->remove(map, key, !map->base.store_pointer);
1054 } 1057 }
1055 1058
1056 /** 1059 /**
1057 * Removes a key/value-pair from the map by using the key. 1060 * Removes a key/value-pair from the map by using the key.
1058 * 1061 *
1064 __attribute__((__nonnull__, __warn_unused_result__)) 1067 __attribute__((__nonnull__, __warn_unused_result__))
1065 static inline void *cx_map_remove_and_get_cxstr( 1068 static inline void *cx_map_remove_and_get_cxstr(
1066 CxMap *map, 1069 CxMap *map,
1067 cxstring key 1070 cxstring key
1068 ) { 1071 ) {
1069 return map->cl->remove(map, cx_hash_key_cxstr(key), !map->store_pointer); 1072 return map->cl->remove(map, cx_hash_key_cxstr(key), !map->base.store_pointer);
1070 } 1073 }
1071 1074
1072 /** 1075 /**
1073 * Removes a key/value-pair from the map by using the key. 1076 * Removes a key/value-pair from the map by using the key.
1074 * 1077 *
1080 __attribute__((__nonnull__, __warn_unused_result__)) 1083 __attribute__((__nonnull__, __warn_unused_result__))
1081 static inline void *cx_map_remove_and_get_mustr( 1084 static inline void *cx_map_remove_and_get_mustr(
1082 CxMap *map, 1085 CxMap *map,
1083 cxmutstr key 1086 cxmutstr key
1084 ) { 1087 ) {
1085 return map->cl->remove(map, cx_hash_key_cxstr(key), !map->store_pointer); 1088 return map->cl->remove(map, cx_hash_key_cxstr(key), !map->base.store_pointer);
1086 } 1089 }
1087 1090
1088 /** 1091 /**
1089 * Removes a key/value-pair from the map by using the key. 1092 * Removes a key/value-pair from the map by using the key.
1090 * 1093 *
1096 __attribute__((__nonnull__, __warn_unused_result__)) 1099 __attribute__((__nonnull__, __warn_unused_result__))
1097 static inline void *cx_map_remove_and_get_str( 1100 static inline void *cx_map_remove_and_get_str(
1098 CxMap *map, 1101 CxMap *map,
1099 char const *key 1102 char const *key
1100 ) { 1103 ) {
1101 return map->cl->remove(map, cx_hash_key_str(key), !map->store_pointer); 1104 return map->cl->remove(map, cx_hash_key_str(key), !map->base.store_pointer);
1102 } 1105 }
1103 1106
1104 /** 1107 /**
1105 * Removes a key/value-pair from the map by using the key. 1108 * Removes a key/value-pair from the map by using the key.
1106 * 1109 *

mercurial