@@ -19,26 +19,25 @@ OF_ASSUME_NONNULL_BEGIN /** @file */ /** - * @struct of_map_table_functions_t OFMapTable.h ObjFW/OFMapTable.h + * @struct OFMapTableFunctions OFMapTable.h ObjFW/OFMapTable.h * * @brief A struct describing the functions to be used by the map table. */ -struct of_map_table_functions_t { +typedef struct { /** The function to retain keys / objects */ void *_Nullable (*_Nullable retain)(void *_Nullable object); /** The function to release keys / objects */ void (*_Nullable release)(void *_Nullable object); /** The function to hash keys */ unsigned long (*_Nullable hash)(void *_Nullable object); /** The function to compare keys / objects */ bool (*_Nullable equal)(void *_Nullable object1, void *_Nullable object2); -}; -typedef struct of_map_table_functions_t of_map_table_functions_t; +} OFMapTableFunctions; #ifdef OF_HAVE_BLOCKS /** * @brief A block for enumerating an OFMapTable. * @@ -45,21 +44,21 @@ * @param key The current key * @param object The current object * @param stop A pointer to a variable that can be set to true to stop the * enumeration */ -typedef void (^of_map_table_enumeration_block_t)(void *_Nullable key, +typedef void (^OFMapTableEnumerationBlock)(void *_Nullable key, void *_Nullable object, bool *stop); /** * @brief A block for replacing objects in an OFMapTable. * * @param key The key of the object to replace * @param object The object to replace * @return The object to replace the object with */ -typedef void *_Nullable (^of_map_table_replace_block_t)(void *_Nullable key, +typedef void *_Nullable (^OFMapTableReplaceBlock)(void *_Nullable key, void *_Nullable object); #endif @class OFMapTableEnumerator; @@ -70,26 +69,26 @@ * and objects should be retained, released, compared and hashed. */ OF_SUBCLASSING_RESTRICTED @interface OFMapTable: OFObject { - of_map_table_functions_t _keyFunctions, _objectFunctions; - struct of_map_table_bucket *_Nonnull *_Nullable _buckets; + OFMapTableFunctions _keyFunctions, _objectFunctions; + struct OFMapTableBucket *_Nonnull *_Nullable _buckets; unsigned long _count, _capacity; unsigned char _rotate; unsigned long _mutations; } /** * @brief The key functions used by the map table. */ -@property (readonly, nonatomic) of_map_table_functions_t keyFunctions; +@property (readonly, nonatomic) OFMapTableFunctions keyFunctions; /** * @brief The object functions used by the map table. */ -@property (readonly, nonatomic) of_map_table_functions_t objectFunctions; +@property (readonly, nonatomic) OFMapTableFunctions objectFunctions; /** * @brief The number of objects in the map table. */ @property (readonly, nonatomic) size_t count; @@ -99,13 +98,12 @@ * * @param keyFunctions A structure of functions for handling keys * @param objectFunctions A structure of functions for handling objects * @return A new autoreleased OFMapTable */ -+ (instancetype)mapTableWithKeyFunctions: (of_map_table_functions_t)keyFunctions - objectFunctions: (of_map_table_functions_t) - objectFunctions; ++ (instancetype)mapTableWithKeyFunctions: (OFMapTableFunctions)keyFunctions + objectFunctions: (OFMapTableFunctions)objectFunctions; /** * @brief Creates a new OFMapTable with the specified key functions, object * functions and capacity. * @@ -113,13 +111,12 @@ * @param objectFunctions A structure of functions for handling objects * @param capacity A hint about the count of elements expected to be in the map * table * @return A new autoreleased OFMapTable */ -+ (instancetype)mapTableWithKeyFunctions: (of_map_table_functions_t)keyFunctions - objectFunctions: (of_map_table_functions_t) - objectFunctions ++ (instancetype)mapTableWithKeyFunctions: (OFMapTableFunctions)keyFunctions + objectFunctions: (OFMapTableFunctions)objectFunctions capacity: (size_t)capacity; - (instancetype)init OF_UNAVAILABLE; /** @@ -128,12 +125,12 @@ * * @param keyFunctions A structure of functions for handling keys * @param objectFunctions A structure of functions for handling objects * @return An initialized OFMapTable */ -- (instancetype)initWithKeyFunctions: (of_map_table_functions_t)keyFunctions - objectFunctions: (of_map_table_functions_t)objectFunctions; +- (instancetype)initWithKeyFunctions: (OFMapTableFunctions)keyFunctions + objectFunctions: (OFMapTableFunctions)objectFunctions; /** * @brief Initializes an already allocated OFMapTable with the specified key * functions, object functions and capacity. * @@ -141,12 +138,12 @@ * @param objectFunctions A structure of functions for handling objects * @param capacity A hint about the count of elements expected to be in the map * table * @return An initialized OFMapTable */ -- (instancetype)initWithKeyFunctions: (of_map_table_functions_t)keyFunctions - objectFunctions: (of_map_table_functions_t)objectFunctions +- (instancetype)initWithKeyFunctions: (OFMapTableFunctions)keyFunctions + objectFunctions: (OFMapTableFunctions)objectFunctions capacity: (size_t)capacity OF_DESIGNATED_INITIALIZER; /** * @brief Returns the object for the given key or NULL if the key was not found. @@ -160,12 +157,11 @@ * @brief Sets an object for a key. * * @param key The key to set * @param object The object to set the key to */ -- (void)setObject: (nullable void *)object - forKey: (nullable void *)key; +- (void)setObject: (nullable void *)object forKey: (nullable void *)key; /** * @brief Removes the object for the specified key from the map table. * * @param key The key whose object should be removed @@ -216,19 +212,18 @@ /** * @brief Executes a block for each key / object pair. * * @param block The block to execute for each key / object pair. */ -- (void)enumerateKeysAndObjectsUsingBlock: - (of_map_table_enumeration_block_t)block; +- (void)enumerateKeysAndObjectsUsingBlock: (OFMapTableEnumerationBlock)block; /** * @brief Replaces each object with the object returned by the block. * * @param block The block which returns a new object for each object */ -- (void)replaceObjectsUsingBlock: (of_map_table_replace_block_t)block; +- (void)replaceObjectsUsingBlock: (OFMapTableReplaceBlock)block; #endif @end /** * @class OFMapTableEnumerator OFMapTable.h ObjFW/OFMapTable.h @@ -237,11 +232,11 @@ * keys or objects. */ @interface OFMapTableEnumerator: OFObject { OFMapTable *_mapTable; - struct of_map_table_bucket *_Nonnull *_Nullable _buckets; + struct OFMapTableBucket *_Nonnull *_Nullable _buckets; unsigned long _capacity, _mutations, *_Nullable _mutationsPtr; unsigned long _position; } - (instancetype)init OF_UNAVAILABLE;