]> err.no Git - sope/blob - libFoundation/Foundation/NSSet.h
Drop apache 1 build-dependency
[sope] / libFoundation / Foundation / NSSet.h
1 /* 
2    NSSet.h
3
4    Copyright (C) 1995, 1996 Ovidiu Predescu and Mircea Oancea.
5    All rights reserved.
6
7    Author: Mircea Oancea <mircea@jupiter.elcom.pub.ro>
8
9    This file is part of libFoundation.
10
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
15    documentation.
16
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.
23 */
24
25 #ifndef __NSSet_h__
26 #define __NSSet_h__
27
28 #include <stdarg.h>
29 #include <Foundation/NSObject.h>
30 #include <Foundation/NSMapTable.h>
31 #include <Foundation/NSHashTable.h>
32 #include <Foundation/NSUtilities.h>
33
34 @class NSString;
35 @class NSArray;
36 @class NSDictionary;
37 @class NSEnumerator;
38
39 /*
40  * NSSet class
41  */
42
43 @interface NSSet : NSObject <NSCoding, NSCopying, NSMutableCopying>
44
45 /* Allocating and Initializing a Set */
46
47 + (id)allocWithZone:(NSZone*)zone;
48 + (id)set;
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;
61
62 /* Querying the Set */
63
64 - (NSArray*)allObjects;
65 - (id)anyObject;
66 - (BOOL)containsObject:(id)anObject;
67 - (unsigned int)count;
68 - (id)member:(id)anObject;
69 - (NSEnumerator*)objectEnumerator;
70
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;
77
78 /* Comparing Sets */
79
80 - (BOOL)intersectsSet:(NSSet*)otherSet;
81 - (BOOL)isEqualToSet:(NSSet*)otherSet;
82 - (BOOL)isSubsetOfSet:(NSSet*)otherSet;
83
84 /* Creating a String Description of the Set */
85
86 - (NSString*)description;
87 - (NSString*)descriptionWithLocale:(NSDictionary*)locale;
88 - (NSString*)descriptionWithLocale:(NSDictionary*)locale
89    indent:(unsigned int)level;
90
91 @end
92
93 /*
94  * NSMutableSet
95  */
96
97 @interface NSMutableSet : NSSet
98
99 + (id)allocWithZone:(NSZone*)zone;
100 + (id)setWithCapacity:(unsigned)numItems;
101 - (id)initWithCapacity:(unsigned)numItems;
102
103 /* Adding Objects */
104
105 - (void)addObject:(id)object;
106 - (void)addObjectsFromArray:(NSArray *)array;
107 - (void)unionSet:(NSSet *)other;
108 - (void)setSet:(NSSet *)other;
109
110 /* Removing Objects */
111
112 - (void)intersectSet:(NSSet *)other;
113 - (void)minusSet:(NSSet *)other;
114 - (void)removeAllObjects;
115 - (void)removeObject:(id)object;
116
117 @end
118
119 /*
120  * NSCountedSet Class
121  */
122
123 @interface NSCountedSet : NSMutableSet
124 {
125         NSMapTable*     table;
126 }
127
128 /* Allocating and Initializing */
129
130 - (id)init;
131 - (id)initWithObjects:(id*)objects count:(unsigned int)count;
132 - (id)initWithSet:(NSSet*)set copyItems:(BOOL)flag;
133
134 /* Accessing keys and values */
135
136 - (unsigned int)count;
137 - (id)member:(id)anObject;
138 - (NSEnumerator*)objectEnumerator;
139
140 /* Add and remove entries */
141
142 - (void)addObject:(id)object;
143 - (void)removeObject:(id)object;
144 - (void)removeAllObjects;
145
146 /* Querying the NSCountedSet */
147
148 - (unsigned)countForObject:(id)anObject;
149
150 /* Private */
151
152 - (void)__setObjectEnumerator:(void*)en;
153
154 @end
155
156 #endif /* __NSSet_h__ */
157
158 /*
159   Local Variables:
160   c-basic-offset: 4
161   tab-width: 8
162   End:
163 */