Differences From Artifact [0fe90e5221]:
- File
src/OFSet.h
— part of check-in
[44f45c2e35]
at
2017-01-09 17:36:36
on branch trunk
— Update copyright
Forgot to add 2017, even though I already did quite some changes in
2017. (user: js, size: 8127) [annotate] [blame] [check-ins using]
To Artifact [48306f95d4]:
- File
src/OFSet.h
— part of check-in
[4af49a13c3]
at
2017-05-07 20:10:13
on branch trunk
— Small code style change
Casts are now written like types in variable declarations. (user: js, size: 8143) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
57 58 59 60 61 62 63 | * * @brief An abstract class for an unordered set of unique objects. * * @warning Do not mutate objects that are in a set! Changing the hash of * objects in a set breaks the internal representation of the set! */ #ifdef OF_HAVE_GENERICS | | | | | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | * * @brief An abstract class for an unordered set of unique objects. * * @warning Do not mutate objects that are in a set! Changing the hash of * objects in a set breaks the internal representation of the set! */ #ifdef OF_HAVE_GENERICS @interface OFSet<ObjectType>: #else # ifndef DOXYGEN # define ObjectType id # endif @interface OFSet: #endif OFObject <OFCollection, OFCopying, OFMutableCopying, OFSerialization> /*! * @brief Creates a new set. * * @return A new, autoreleased set */ + (instancetype)set; /*! * @brief Creates a new set with the specified set. * * @param set The set to initialize the set with * @return A new, autoreleased set with the specified set */ + (instancetype)setWithSet: (OFSet OF_GENERIC(ObjectType) *)set; /*! * @brief Creates a new set with the specified array. * * @param array The array to initialize the set with * @return A new, autoreleased set with the specified array */ + (instancetype)setWithArray: (OFArray OF_GENERIC(ObjectType) *)array; /*! * @brief Creates a new set with the specified objects. * * @param firstObject The first object for the set * @return A new, autoreleased set with the specified objects */ |
︙ | ︙ | |||
112 113 114 115 116 117 118 | /*! * @brief Initializes an already allocated set with the specified set. * * @param set The set to initialize the set with * @return An initialized set with the specified set */ | | | | 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | /*! * @brief Initializes an already allocated set with the specified set. * * @param set The set to initialize the set with * @return An initialized set with the specified set */ - initWithSet: (OFSet OF_GENERIC(ObjectType) *)set; /*! * @brief Initializes an already allocated set with the specified array. * * @param array The array to initialize the set with * @return An initialized set with the specified array */ - initWithArray: (OFArray OF_GENERIC(ObjectType) *)array; /*! * @brief Initializes an already allocated set with the specified objects. * * @param firstObject The first object for the set * @return An initialized set with the specified objects */ |
︙ | ︙ | |||
156 157 158 159 160 161 162 | arguments: (va_list)arguments; /*! * @brief Returns whether the receiver is a subset of the specified set. * * @return Whether the receiver is a subset of the specified set */ | | | | | | | | | | | 156 157 158 159 160 161 162 163 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 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | arguments: (va_list)arguments; /*! * @brief Returns whether the receiver is a subset of the specified set. * * @return Whether the receiver is a subset of the specified set */ - (bool)isSubsetOfSet: (OFSet OF_GENERIC(ObjectType) *)set; /*! * @brief Returns whether the receiver and the specified set have at least one * object in common. * * @return Whether the receiver and the specified set have at least one object * in common */ - (bool)intersectsSet: (OFSet OF_GENERIC(ObjectType) *)set; /*! * @brief Creates a new set which contains the objects which are in the * receiver, but not in the specified set. * * @param set The set whose objects will not be in the new set */ - (OFSet OF_GENERIC(ObjectType) *)setBySubtractingSet: (OFSet OF_GENERIC(ObjectType) *)set; /*! * @brief Creates a new set by creating the intersection of the receiver and * the specified set. * * @param set The set to intersect with */ - (OFSet OF_GENERIC(ObjectType) *)setByIntersectingWithSet: (OFSet OF_GENERIC(ObjectType) *)set; /*! * @brief Creates a new set by creating the union of the receiver and the * specified set. * * @param set The set to create the union with */ - (OFSet OF_GENERIC(ObjectType) *)setByAddingSet: (OFSet OF_GENERIC(ObjectType) *)set; /*! * @brief Returns an array of all objects in the set. * * @return An array of all objects in the set */ - (OFArray OF_GENERIC(ObjectType) *)allObjects; /*! * @brief Returns an arbitrary object in the set. * * @return An arbitrary object in the set */ - (ObjectType)anyObject; |
︙ | ︙ | |||
230 231 232 233 234 235 236 | * specified key for each object is returned. * * @note Unlike with @ref OFArray, any nil values are removed! * * @param key The key of the value to return * @return The value for the specified key */ | | | | | | 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | * specified key for each object is returned. * * @note Unlike with @ref OFArray, any nil values are removed! * * @param key The key of the value to return * @return The value for the specified key */ - (nullable id)valueForKey: (OFString *)key; /*! * @brief Set the value for the specified key * * If the key starts with an `@`, the `@` is stripped and * `[super setValue:forKey:]` is called. * If the key does not start with an `@`, @ref setValue:forKey: is called for * each object. * * @note A @ref OFNull value is translated to nil! * * @param value The value for the specified key * @param key The key of the value to set */ - (void)setValue: (nullable id)value forKey: (OFString *)key; /*! * @brief Returns an OFEnumerator to enumerate through all objects of the set. * * @returns An OFEnumerator to enumerate through all objects of the set */ - (OFEnumerator OF_GENERIC(ObjectType) *)objectEnumerator; #ifdef OF_HAVE_BLOCKS /*! * @brief Executes a block for each object in the set. * * @param block The block to execute for each object in the set */ - (void)enumerateObjectsUsingBlock: (of_set_enumeration_block_t)block; /*! * @brief Creates a new set, only containing the objects for which the block * returns true. * * @param block A block which determines if the object should be in the new set * @return A new, autoreleased OFSet */ - (OFSet OF_GENERIC(ObjectType) *)filteredSetUsingBlock: (of_set_filter_block_t)block; #endif @end #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # undef ObjectType #endif OF_ASSUME_NONNULL_END #import "OFMutableSet.h" |