ObjFW  Diff

Differences From Artifact [d4d456e6cd]:

To Artifact [03ba48a726]:


13
14
15
16
17
18
19


20
21
22
23
24
25
26
27
28
29

30
31

32
33

34

35

36
37
38
39
40
41
42
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

31
32

33
34

35
36
37

38
39
40
41
42
43
44
45







+
+









-
+

-
+

-
+

+
-
+







 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFObject.h"
#import "OFEnumerator.h"

OF_ASSUME_NONNULL_BEGIN

/*! @file */

/*!
 * @struct of_map_table_functions_t OFMapTable.h ObjFW/OFMapTable.h
 *
 * @brief A struct describing the functions to be used by the map table.
 */
typedef struct {
	/// The function to retain keys / values
	void* (*retain)(void *value);
	__nonnull void* (*__nullable retain)(__nonnull void *value);
	/// The function to release keys / values
	void (*release)(void *value);
	void (*__nullable release)(__nonnull void *value);
	/// The function to hash keys
	uint32_t (*hash)(void *value);
	uint32_t (*__nullable hash)(__nonnull void *value);
	/// The function to compare keys / values
	bool (*__nullable equal)(__nonnull void *value1,
	bool (*equal)(void *value1, void *value2);
	    __nonnull void *value2);
} of_map_table_functions_t;

#ifdef OF_HAVE_BLOCKS
/*!
 * @brief A block for enumerating an OFMapTable.
 *
 * @param key The current key
50
51
52
53
54
55
56
57

58
59
60
61
62
63
64
53
54
55
56
57
58
59

60
61
62
63
64
65
66
67







-
+







/*!
 * @brief A block for replacing values in an OFMapTable.
 *
 * @param key The key of the value to replace
 * @param value The value to replace
 * @return The value to replace the value with
 */
typedef void* (^of_map_table_replace_block_t)(void *key, void *value);
typedef __nonnull void* (^of_map_table_replace_block_t)(void *key, void *value);
#endif

@class OFMapTableEnumerator;

/*!
 * @class OFMapTable OFMapTable.h ObjFW/OFMapTable.h
 *
129
130
131
132
133
134
135
136

137
138
139

140
141

142
143
144
145
146
147
148
132
133
134
135
136
137
138

139
140
141

142
143

144
145
146
147
148
149
150
151







-
+


-
+

-
+







 * @brief Returns the number of objects in the map table.
 *
 * @return The number of objects in the map table
 */
- (size_t)count;

/*!
 * @brief Returns the value for the given key or nil if the key was not found.
 * @brief Returns the value for the given key or NULL if the key was not found.
 *
 * @param key The key whose object should be returned
 * @return The value for the given key or nil if the key was not found
 * @return The value for the given key or NULL if the key was not found
 */
- (void*)valueForKey: (void*)key;
- (nullable void*)valueForKey: (void*)key;

/*!
 * @brief Sets a value for a key.
 *
 * @param key The key to set
 * @param value The value to set the key to
 */
164
165
166
167
168
169
170
171

172
173
174
175
176
177
178
179
180
181

182
183
184
185
186
187
188
167
168
169
170
171
172
173

174
175
176
177
178
179
180
181
182
183

184
185
186
187
188
189
190
191







-
+









-
+







/*!
 * @brief Checks whether the map table contains a value equal to the specified
 *	  value.
 *
 * @param value The value which is checked for being in the map table
 * @return A boolean whether the map table contains the specified value
*/
- (bool)containsValue: (void*)value;
- (bool)containsValue: (nullable void*)value;

/*!
 * @brief Checks whether the map table contains a value with the specified
 *        address.
 *
 * @param value The value which is checked for being in the map table
 * @return A boolean whether the map table contains a value with the specified
 *	   address.
 */
- (bool)containsValueIdenticalTo: (void*)value;
- (bool)containsValueIdenticalTo: (nullable void*)value;

/*!
 * @brief Returns an OFMapTableEnumerator to enumerate through the map table's
 *	  keys.
 *
 * @return An OFMapTableEnumerator to enumerate through the map table's keys
 */
253
254
255
256
257
258
259


256
257
258
259
260
261
262
263
264







+
+

/*!
 * @brief Resets the enumerator, so the next call to nextKey returns the first
 *	  key again.
 */
- (void)reset;
@end

OF_ASSUME_NONNULL_END