ObjFW
OFMutableSet.h
1 /*
2  * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
3  *
4  * All rights reserved.
5  *
6  * This file is part of ObjFW. It may be distributed under the terms of the
7  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
8  * the packaging of this file.
9  *
10  * Alternatively, it may be distributed under the terms of the GNU General
11  * Public License, either version 2 or 3, which can be found in the file
12  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
13  * file.
14  */
15 
16 #import "OFSet.h"
17 
18 OF_ASSUME_NONNULL_BEGIN
19 
28 @interface OFMutableSet OF_GENERIC(ObjectType): OFSet OF_GENERIC(ObjectType)
29 #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN)
30 # define ObjectType id
31 #endif
39 + (instancetype)setWithCapacity: (size_t)capacity;
40 
46 - (instancetype)init OF_DESIGNATED_INITIALIZER;
47 
55 - (instancetype)initWithCapacity: (size_t)capacity OF_DESIGNATED_INITIALIZER;
56 
62 - (void)addObject: (ObjectType)object;
63 
69 - (void)removeObject: (ObjectType)object;
70 
76 - (void)minusSet: (OFSet OF_GENERIC(ObjectType) *)set;
77 
84 - (void)intersectSet: (OFSet OF_GENERIC(ObjectType) *)set;
85 
91 - (void)unionSet: (OFSet OF_GENERIC(ObjectType) *)set;
92 
96 - (void)removeAllObjects;
97 
101 - (void)makeImmutable;
102 #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN)
103 # undef ObjectType
104 #endif
105 @end
106 
107 OF_ASSUME_NONNULL_END
An abstract class for a mutable unordered set of unique objects.
Definition: OFMutableSet.h:29
void removeAllObjects()
Removes all objects from the set.
Definition: OFMutableSet.m:187
instancetype init()
Initializes an already allocated OFMutableSet to be empty.
Definition: OFMutableSet.m:110
void makeImmutable()
Converts the mutable set to an immutable set.
Definition: OFMutableSet.m:198
An abstract class for an unordered set of unique objects.
Definition: OFSet.h:65