4 Copyright (C) 1995, 1996 Ovidiu Predescu and Mircea Oancea.
7 Author: Mircea Oancea <mircea@jupiter.elcom.pub.ro>
9 This file is part of libFoundation.
11 Permission to use, copy, modify, and distribute this software and its
12 documentation for any purpose and without fee is hereby granted, provided
13 that the above copyright notice appear in all copies and that both that
14 copyright notice and this permission notice appear in supporting
17 We disclaim all warranties with regard to this software, including all
18 implied warranties of merchantability and fitness, in no event shall
19 we be liable for any special, indirect or consequential damages or any
20 damages whatsoever resulting from loss of use, data or profits, whether in
21 an action of contract, negligence or other tortious action, arising out of
22 or in connection with the use or performance of this software.
29 #include <Foundation/NSObject.h>
30 #include <Foundation/NSMapTable.h>
31 #include <Foundation/NSHashTable.h>
32 #include <Foundation/NSUtilities.h>
43 @interface NSSet : NSObject <NSCoding, NSCopying, NSMutableCopying>
45 /* Allocating and Initializing a Set */
47 + (id)allocWithZone:(NSZone*)zone;
49 + (id)setWithArray:(NSArray*)array;
50 + (id)setWithObject:(id)anObject;
51 + (id)setWithObjects:(id)firstObj,...;
52 + (id)setWithObjects:(id*)objects count:(unsigned int)count;
53 + (id)setWithSet:(NSSet*)aSet;
54 - (id)initWithArray:(NSArray*)array;
55 - (id)initWithObjects:(id)firstObj,...;
56 - (id)initWithObject:(id)firstObj arglist:(va_list)arglist;
57 - (id)initWithObjects:(id*)objects count:(unsigned int)count;
58 - (id)initWithSet:(NSSet*)anotherSet;
59 - (id)initWithSet:(NSSet*)set copyItems:(BOOL)flag;
60 - (id)initWithSet:(NSSet*)aSet;
62 /* Querying the Set */
64 - (NSArray*)allObjects;
66 - (BOOL)containsObject:(id)anObject;
67 - (unsigned int)count;
68 - (id)member:(id)anObject;
69 - (NSEnumerator*)objectEnumerator;
71 /* Sending Messages to Elements of the Set */
72 - (void)makeObjectsPerformSelector:(SEL)aSelector;
73 - (void)makeObjectsPerformSelector:(SEL)aSelector withObject:(id)anObject;
74 /* Obsolete methods */
75 - (void)makeObjectsPerform:(SEL)aSelector;
76 - (void)makeObjectsPerform:(SEL)aSelector withObject:(id)anObject;
80 - (BOOL)intersectsSet:(NSSet*)otherSet;
81 - (BOOL)isEqualToSet:(NSSet*)otherSet;
82 - (BOOL)isSubsetOfSet:(NSSet*)otherSet;
84 /* Creating a String Description of the Set */
86 - (NSString*)description;
87 - (NSString*)descriptionWithLocale:(NSDictionary*)locale;
88 - (NSString*)descriptionWithLocale:(NSDictionary*)locale
89 indent:(unsigned int)level;
97 @interface NSMutableSet : NSSet
99 + (id)allocWithZone:(NSZone*)zone;
100 + (id)setWithCapacity:(unsigned)numItems;
101 - (id)initWithCapacity:(unsigned)numItems;
105 - (void)addObject:(id)object;
106 - (void)addObjectsFromArray:(NSArray *)array;
107 - (void)unionSet:(NSSet *)other;
108 - (void)setSet:(NSSet *)other;
110 /* Removing Objects */
112 - (void)intersectSet:(NSSet *)other;
113 - (void)minusSet:(NSSet *)other;
114 - (void)removeAllObjects;
115 - (void)removeObject:(id)object;
123 @interface NSCountedSet : NSMutableSet
128 /* Allocating and Initializing */
131 - (id)initWithObjects:(id*)objects count:(unsigned int)count;
132 - (id)initWithSet:(NSSet*)set copyItems:(BOOL)flag;
134 /* Accessing keys and values */
136 - (unsigned int)count;
137 - (id)member:(id)anObject;
138 - (NSEnumerator*)objectEnumerator;
140 /* Add and remove entries */
142 - (void)addObject:(id)object;
143 - (void)removeObject:(id)object;
144 - (void)removeAllObjects;
146 /* Querying the NSCountedSet */
148 - (unsigned)countForObject:(id)anObject;
152 - (void)__setObjectEnumerator:(void*)en;
156 #endif /* __NSSet_h__ */