Oolite 1.91.0.7644-241112-7f5034b
Loading...
Searching...
No Matches
OOWeakSet.h
Go to the documentation of this file.
1/*
2
3OOWeakSet.h
4
5A mutable set of weak references to objects conforming to OOWeakReferenceSupport.
6
7Semantics:
8 * When an object in the set is deallocated, the object is removed from the
9 set and the set's count drops. There is no notification for this. As such,
10 there is no such thing as an immutable weak set.
11 * Objects are uniqued by pointer equality, not isEquals:.
12 * OOWeakSet is not thread-safe. It not only requires that all operations on
13 it happen on one thread, but also that objects it's watching are (finally)
14 released on that thread.
15
16
17LIMITATION: fast enumeration and Oolite's foreach() macro are not supported.
18
19
20Written by Jens Ayton in 2012 for Oolite.
21This code is hereby placed in the public domain.
22
23*/
24
25#import "OOCocoa.h"
26#import "OOWeakReference.h"
27
28
29@interface OOWeakSet: NSObject <NSCopying, NSMutableCopying>
30{
31@private
32 NSMutableSet *_objects;
34
35- (id) init;
36- (id) initWithCapacity:(NSUInteger)capacity; // As with Foundation collections, capacity is only a hint.
37
38+ (instancetype) set;
39+ (instancetype) setWithCapacity:(NSUInteger)capacity;
40
41- (NSUInteger) count;
42- (BOOL) containsObject:(id<OOWeakReferenceSupport>)object;
43- (NSEnumerator *) objectEnumerator;
44
45- (void) addObject:(id<OOWeakReferenceSupport>)object; // Unlike NSSet, adding nil fails silently.
46- (void) removeObject:(id<OOWeakReferenceSupport>)object; // Like NSSet, does not complain if object is not already a member.
47
48- (void) addObjectsByEnumerating:(NSEnumerator *)enumerator;
49
50- (void) makeObjectsPerformSelector:(SEL)selector;
51- (void) makeObjectsPerformSelector:(SEL)selector withObject:(id)argument;
52
53- (NSArray *) allObjects;
54
55- (void) removeAllObjects;
56
57@end
unsigned count
NSMutableSet * _objects
Definition OOWeakSet.h:33