17 #ifndef __STDC_LIMIT_MACROS
18 # define __STDC_LIMIT_MACROS
20 #ifndef __STDC_CONSTANT_MACROS
21 # define __STDC_CONSTANT_MACROS
27 #import "OFCollection.h"
28 #import "OFSerialization.h"
30 OF_ASSUME_NONNULL_BEGIN
34 @class OFArray OF_GENERIC(ObjectType);
63 #ifdef OF_HAVE_GENERICS
64 @interface OFSet <ObjectType>:
67 # define ObjectType id
85 + (instancetype)setWithSet: (OFSet OF_GENERIC(ObjectType)*)
set;
93 + (instancetype)setWithArray: (OFArray OF_GENERIC(ObjectType)*)array;
101 + (instancetype)setWithObjects: (ObjectType)firstObject, ...;
110 + (instancetype)setWithObjects: (ObjectType const OF_NONNULL *OF_NONNULL)objects
119 - initWithSet: (OFSet OF_GENERIC(ObjectType)*)
set;
127 - initWithArray: (OFArray OF_GENERIC(ObjectType)*)array;
135 - initWithObjects: (ObjectType)firstObject, ...;
144 - initWithObjects: (ObjectType const OF_NONNULL *OF_NONNULL)objects
155 - initWithObject: (ObjectType)firstObject
156 arguments: (va_list)arguments;
163 - (bool)isSubsetOfSet: (OFSet OF_GENERIC(ObjectType)*)
set;
172 - (bool)intersectsSet: (OFSet OF_GENERIC(ObjectType)*)
set;
180 - (OFSet OF_GENERIC(ObjectType)*)setBySubtractingSet:
181 (OFSet OF_GENERIC(ObjectType)*)
set;
189 - (OFSet OF_GENERIC(ObjectType)*)setByIntersectingWithSet:
190 (OFSet OF_GENERIC(ObjectType)*)
set;
198 - (OFSet OF_GENERIC(ObjectType)*)setByAddingSet:
199 (OFSet OF_GENERIC(ObjectType)*)
set;
206 - (OFArray OF_GENERIC(ObjectType)*)
allObjects;
222 - (bool)containsObject: (nullable ObjectType)object;
231 #ifdef OF_HAVE_BLOCKS
237 - (void)enumerateObjectsUsingBlock: (of_set_enumeration_block_t)block;
246 - (OFSet OF_GENERIC(ObjectType)*)filteredSetUsingBlock:
247 (of_set_filter_block_t)block;
250 #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN)
254 OF_ASSUME_NONNULL_END
256 #import "OFMutableSet.h"
void(^ of_set_enumeration_block_t)(id object, bool *stop)
A block for enumerating an OFSet.
Definition: OFSet.h:44
A protocol for serializing objects.
Definition: OFSerialization.h:30
bool(^ of_set_filter_block_t)(id object)
A block for filtering an OFSet.
Definition: OFSet.h:52
OFEnumerator OF_GENERIC(ObjectType objectEnumerator()
Returns an OFEnumerator to enumerate through all objects of the set.
Definition: OFSet.m:221
An abstract class for storing objects in an array.
Definition: OFArray.h:95
The root class for all other classes inside ObjFW.
Definition: OFObject.h:364
size_t count()
Returns the number of objects in the collection.
A protocol with methods common for all collections.
Definition: OFCollection.h:26
An abstract class for an unordered set of unique objects.
Definition: OFSet.h:69
instancetype set()
Creates a new set.
Definition: OFSet.m:120
A protocol for the creation of mutable copies.
Definition: OFObject.h:917
A protocol for the creation of copies.
Definition: OFObject.h:896
ObjectType anyObject()
Returns an arbitrary object in the set.
Definition: OFSet.m:425
OFArray OF_GENERIC(ObjectType allObjects()
Returns an array of all objects in the set.
Definition: OFSet.m:416