~ubuntu-branches/ubuntu/karmic/gnustep-base/karmic

« back to all changes in this revision

Viewing changes to Source/NSSet.m

  • Committer: Bazaar Package Importer
  • Author(s): Eric Heintzmann
  • Date: 2005-04-17 00:14:38 UTC
  • mfrom: (1.2.1 upstream) (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050417001438-enf0y07c9tku85z1
Tags: 1.10.3-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/** NSSet - Set object to store key/value pairs
2
2
   Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc.
3
 
   
 
3
 
4
4
   Written by:  Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
5
5
   Created: Sep 1995
6
 
   
 
6
 
7
7
   This file is part of the GNUstep Base Library.
8
 
   
 
8
 
9
9
   This library is free software; you can redistribute it and/or
10
10
   modify it under the terms of the GNU Library General Public
11
11
   License as published by the Free Software Foundation; either
12
12
   version 2 of the License, or (at your option) any later version.
13
 
   
 
13
 
14
14
   This library is distributed in the hope that it will be useful,
15
15
   but WITHOUT ANY WARRANTY; without even the implied warranty of
16
16
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
17
   Library General Public License for more details.
18
 
   
 
18
 
19
19
   You should have received a copy of the GNU Library General Public
20
20
   License along with this library; if not, write to the Free
21
21
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
22
22
 
23
23
   <title>NSSet class reference</title>
24
 
   $Date: 2001/12/18 16:54:15 $ $Revision: 1.39 $
 
24
   $Date: 2005/02/22 11:22:44 $ $Revision: 1.55 $
25
25
   */
26
26
 
27
 
#include <config.h>
28
 
#include <base/behavior.h>
29
 
#include <Foundation/NSSet.h>
30
 
#include <Foundation/NSCoder.h>
31
 
#include <Foundation/NSArray.h>
32
 
#include <Foundation/NSUtilities.h>
33
 
#include <Foundation/NSString.h>
34
 
#include <Foundation/NSException.h>
35
 
#include <Foundation/NSObjCRuntime.h>
36
 
#include <Foundation/NSDebug.h>
 
27
#include "config.h"
 
28
#include "Foundation/NSSet.h"
 
29
#include "Foundation/NSCoder.h"
 
30
#include "Foundation/NSArray.h"
 
31
#include "Foundation/NSUtilities.h"
 
32
#include "Foundation/NSString.h"
 
33
#include "Foundation/NSException.h"
 
34
#include "Foundation/NSObjCRuntime.h"
 
35
#include "Foundation/NSDebug.h"
 
36
// For private method _decodeArrayOfObjectsForKey:
 
37
#include "Foundation/NSKeyedArchiver.h"
 
38
#include "GNUstepBase/GSCategories.h"
 
39
#include "GSPrivate.h"
37
40
 
38
41
@class  GSSet;
39
42
@class  GSMutableSet;
40
43
 
41
 
@implementation NSSet 
 
44
/**
 
45
 *  <code>NSSet</code> maintains an unordered collection of unique objects
 
46
 *  (according to [NSObject-isEqual:]).  When a duplicate object is added
 
47
 *  to the set, it replaces its old copy.
 
48
 */
 
49
@implementation NSSet
42
50
 
43
51
static Class NSSet_abstract_class;
44
52
static Class NSMutableSet_abstract_class;
68
76
    }
69
77
}
70
78
 
 
79
/**
 
80
 *  New autoreleased empty set.
 
81
 */
71
82
+ (id) set
72
83
{
73
84
  return AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()] init]);
74
85
}
75
86
 
 
87
/**
 
88
 *  New set containing (unique elements of) objects.
 
89
 */
76
90
+ (id) setWithArray: (NSArray*)objects
77
91
{
78
92
  return AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()]
79
93
    initWithArray: objects]);
80
94
}
81
95
 
 
96
/**
 
97
 *  New set containing single object anObject.
 
98
 */
82
99
+ (id) setWithObject: anObject
83
100
{
84
101
  return AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()]
85
102
    initWithObjects: &anObject count: 1]);
86
103
}
87
104
 
88
 
+ (id) setWithObjects: (id*)objects 
 
105
/**
 
106
 *  New set containing (unique elements of) objects.
 
107
 */
 
108
+ (id) setWithObjects: (id*)objects
89
109
                count: (unsigned)count
90
110
{
91
111
  return AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()]
92
112
    initWithObjects: objects count: count]);
93
113
}
94
114
 
 
115
/**
 
116
 *  New set with objects in given nil-terminated list.
 
117
 */
95
118
+ (id) setWithObjects: firstObject, ...
96
119
{
97
120
  id    set;
98
 
  va_list ap;
99
 
  va_start(ap, firstObject);
100
 
  set = [[self allocWithZone: NSDefaultMallocZone()]
101
 
    initWithObjects: firstObject rest: ap];
102
 
  va_end(ap);
 
121
 
 
122
  GS_USEIDLIST(firstObject,
 
123
    set = [[self allocWithZone: NSDefaultMallocZone()]
 
124
      initWithObjects: __objects count: __count]);
103
125
  return AUTORELEASE(set);
104
126
}
105
127
 
 
128
/**
 
129
 *  Copy constructor.
 
130
 */
106
131
+ (id) setWithSet: (NSSet*)aSet
107
132
{
108
133
  return AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()]
114
139
  return NSSet_abstract_class;
115
140
}
116
141
 
 
142
/**
 
143
 * Returns a new copy of the receiver.<br />
 
144
 * The default abstract implementation of a copy is to use the
 
145
 * -initWithSet:copyItems: method with the flag set to YES.<br />
 
146
 * Concrete subclasses generally simply retain and return the receiver.
 
147
 */
117
148
- (id) copyWithZone: (NSZone*)z
118
149
{
119
 
  return RETAIN(self);
 
150
  NSSet *copy = [NSSet_concrete_class allocWithZone: z];
 
151
 
 
152
  return [copy initWithSet: self copyItems: YES];
120
153
}
121
154
 
 
155
/**
 
156
 * Returns the number of objects stored in the set.
 
157
 */
122
158
- (unsigned) count
123
159
{
124
160
  [self subclassResponsibility: _cmd];
127
163
 
128
164
- (void) encodeWithCoder: (NSCoder*)aCoder
129
165
{
130
 
  unsigned      count = [self count];
131
 
  NSEnumerator  *e = [self objectEnumerator];
132
 
  id            o;
133
 
 
134
 
  [aCoder encodeValueOfObjCType: @encode(unsigned) at: &count];
135
 
  while ((o = [e nextObject]) != nil)
136
 
    {
137
 
      [aCoder encodeValueOfObjCType: @encode(id) at: &o];
 
166
  if ([aCoder allowsKeyedCoding])
 
167
    {
 
168
      /* HACK ... MacOS-X seems to code differently if the coder is an
 
169
       * actual instance of NSKeyedArchiver
 
170
       */
 
171
      if ([aCoder class] == [NSKeyedArchiver class])
 
172
        {
 
173
          [(NSKeyedArchiver*)aCoder _encodeArrayOfObjects: [self allObjects]
 
174
                                                   forKey: @"NS.objects"];
 
175
        }
 
176
      else
 
177
        {
 
178
          unsigned      i = 0;
 
179
          NSEnumerator  *e = [self objectEnumerator];
 
180
          id            o;
 
181
 
 
182
          while ((o = [e nextObject]) != nil)
 
183
            {
 
184
              NSString  *key;
 
185
 
 
186
              key = [NSString stringWithFormat: @"NS.object.%u", i++];
 
187
              [(NSKeyedArchiver*)aCoder encodeObject: o forKey: key];
 
188
            }
 
189
        }
 
190
    }
 
191
  else
 
192
    {
 
193
      unsigned          count = [self count];
 
194
      NSEnumerator      *e = [self objectEnumerator];
 
195
      id                o;
 
196
 
 
197
      [aCoder encodeValueOfObjCType: @encode(unsigned) at: &count];
 
198
      while ((o = [e nextObject]) != nil)
 
199
        {
 
200
          [aCoder encodeValueOfObjCType: @encode(id) at: &o];
 
201
        }
138
202
    }
139
203
}
140
204
 
141
205
- (id) initWithCoder: (NSCoder*)aCoder
142
206
{
143
 
  unsigned      count;
144
207
  Class         c;
145
208
 
146
209
  c = GSObjCClass(self);
156
219
      self = [NSMutableSet_concrete_class allocWithZone: NSDefaultMallocZone()];
157
220
      return [self initWithCoder: aCoder];
158
221
    }
159
 
  [aCoder decodeValueOfObjCType: @encode(unsigned) at: &count];
160
 
  {
161
 
    id  objs[count];
162
 
    unsigned    i;
163
 
 
164
 
    for (i = 0; i < count; i++)
165
 
      {
166
 
        [aCoder decodeValueOfObjCType: @encode(id) at: &objs[i]];
167
 
      }
168
 
    return [self initWithObjects: objs count: count];
169
 
  }
170
 
}
171
 
 
172
 
/* This is the designated initializer */
 
222
 
 
223
  if ([aCoder allowsKeyedCoding])
 
224
    {
 
225
      id        array;
 
226
 
 
227
      array = [(NSKeyedUnarchiver*)aCoder _decodeArrayOfObjectsForKey:
 
228
                                                @"NS.objects"];
 
229
      if (array == nil)
 
230
        {
 
231
          unsigned      i = 0;
 
232
          NSString      *key;
 
233
          id            val;
 
234
 
 
235
          array = [NSMutableArray arrayWithCapacity: 2];
 
236
          key = [NSString stringWithFormat: @"NS.object.%u", i];
 
237
          val = [(NSKeyedUnarchiver*)aCoder decodeObjectForKey: key];
 
238
 
 
239
          while (val != nil)
 
240
            {
 
241
              [array addObject: val];
 
242
              i++;
 
243
              key = [NSString stringWithFormat: @"NS.object.%u", i];
 
244
              val = [(NSKeyedUnarchiver*)aCoder decodeObjectForKey: key];
 
245
            }
 
246
        }
 
247
      self = [self initWithArray: array];
 
248
    }
 
249
  else
 
250
    {
 
251
      unsigned  count;
 
252
 
 
253
      [aCoder decodeValueOfObjCType: @encode(unsigned) at: &count];
 
254
      if (count > 0)
 
255
        {
 
256
          unsigned      i;
 
257
          GS_BEGINIDBUF(objs, count);
 
258
        
 
259
          for (i = 0; i < count; i++)
 
260
            {
 
261
              [aCoder decodeValueOfObjCType: @encode(id) at: &objs[i]];
 
262
            }
 
263
          self = [self initWithObjects: objs count: count];
 
264
#if     GS_WITH_GC == 0
 
265
          while (count-- > 0)
 
266
            {
 
267
              [objs[count] release];
 
268
            }
 
269
#endif
 
270
          GS_ENDIDBUF();
 
271
        }
 
272
    }
 
273
  return self;
 
274
}
 
275
 
 
276
/**
 
277
 * <p>In MacOS-X class clusters do not have designated initialisers,
 
278
 * and there is a general rule that -init is treated as the designated
 
279
 * initialiser of the class cluster, but that other intitialisers
 
280
 * may not work s expected an would need to be individually overridden
 
281
 * in any subclass.
 
282
 * </p>
 
283
 * <p>GNUstep tries to make it easier to subclass a class cluster,
 
284
 * by making class clusters follow the same convention as normal
 
285
 * classes, so the designated initialiser is the <em>richest</em>
 
286
 * initialiser.  This means that all other initialisers call the
 
287
 * documented designated initialiser (which calls -init only for
 
288
 * MacOS-X compatibility), and anyone writing a subclass only needs
 
289
 * to override that one initialiser in order to have all the other
 
290
 * ones work.
 
291
 * </p>
 
292
 * <p>For MacOS-X compatibility, you may also need to override various
 
293
 * other initialisers.  Exactly which ones, you will need to determine
 
294
 * by trial on a MacOS-X system ... and may vary between releases of
 
295
 * MacOS-X.  So to be safe, on MacOS-X you probably need to re-implement
 
296
 * <em>all</em> the class cluster initialisers you might use in conjunction
 
297
 * with your subclass.
 
298
 * </p>
 
299
 */
 
300
- (id) init
 
301
{
 
302
  self = [super init];
 
303
  return self;
 
304
}
 
305
 
 
306
/** <init /> <override-subclass />
 
307
 * Initialize to contain (unique elements of) objects.<br />
 
308
 * Calls -init (which does nothing but maintain MacOS-X compatibility),
 
309
 * and needs to be re-implemented in subclasses in order to have all
 
310
 * other initialisers work.
 
311
 */
173
312
- (id) initWithObjects: (id*)objects
174
313
                 count: (unsigned)count
175
314
{
176
 
  [self subclassResponsibility: _cmd];
177
 
  return 0;
 
315
  self = [self init];
 
316
  return self;
178
317
}
179
318
 
 
319
/**
 
320
 *  If anObject is in set, return it (the copy in the set).
 
321
 */
180
322
- (id) member: (id)anObject
181
323
{
182
324
  return [self subclassResponsibility: _cmd];
183
 
  return 0;  
 
325
  return 0;
184
326
}
185
327
 
 
328
/**
 
329
 * Returns a new instance containing the same objects as
 
330
 * the receiver.<br />
 
331
 * The default implementation does this by calling the
 
332
 * -initWithSet:copyItems: method on a newly created object,
 
333
 * and passing it NO to tell it just to retain the items.
 
334
 */
186
335
- (id) mutableCopyWithZone: (NSZone*)z
187
336
{
188
 
  return [[NSMutableSet_concrete_class allocWithZone: z] initWithSet: self];
 
337
  NSMutableSet  *copy = [NSMutableSet_concrete_class allocWithZone: z];
 
338
 
 
339
  return [copy initWithSet: self copyItems: NO];
189
340
}
190
341
 
 
342
/**
 
343
 *  Return enumerator over objects in set.  Order is undefined.
 
344
 */
191
345
- (NSEnumerator*) objectEnumerator
192
346
{
193
347
  return [self subclassResponsibility: _cmd];
194
348
}
195
349
 
196
 
/* Same as NSArray */
197
 
- (id) initWithObjects: firstObject rest: (va_list)ap
198
 
{
199
 
  register      unsigned                i;
200
 
  register      unsigned                curSize;
201
 
  auto          unsigned                prevSize;
202
 
  auto          unsigned                newSize;
203
 
  auto          id                      *objsArray;
204
 
  auto          id                      tmpId;
205
 
 
206
 
  /*    Do initial allocation.  */
207
 
  prevSize = 3;
208
 
  curSize  = 5;
209
 
  objsArray = (id*)NSZoneMalloc(NSDefaultMallocZone(), sizeof(id) * curSize);
210
 
  tmpId = firstObject;
211
 
 
212
 
  /*    Loop through adding objects to array until a nil is
213
 
   *    found.
214
 
   */
215
 
  for (i = 0; tmpId != nil; i++)
216
 
    {
217
 
      /*        Put id into array.      */
218
 
      objsArray[i] = tmpId;
219
 
 
220
 
      /*        If the index equals the current size, increase size.    */
221
 
      if (i == curSize - 1)
222
 
        {
223
 
          /*    Fibonacci series.  Supposedly, for this application,
224
 
           *    the fibonacci series will be more memory efficient.
225
 
           */
226
 
          newSize  = prevSize + curSize;
227
 
          prevSize = curSize;
228
 
          curSize  = newSize;
229
 
 
230
 
          /*    Reallocate object array.        */
231
 
          objsArray = (id*)NSZoneRealloc(NSDefaultMallocZone(), objsArray,
232
 
            sizeof(id) * curSize);
233
 
        }
234
 
      tmpId = va_arg(ap, id);
235
 
    }
236
 
  va_end( ap );
237
 
 
238
 
  /*    Put object ids into NSSet.      */
239
 
  self = [self initWithObjects: objsArray count: i];
240
 
  NSZoneFree(NSDefaultMallocZone(), objsArray);
241
 
  return( self );
242
 
}
243
 
 
244
 
/* Same as NSArray */
 
350
/**
 
351
 *  Initialize with (unique elements of) objects in given nil-terminated list.
 
352
 */
245
353
- (id) initWithObjects: firstObject, ...
246
354
{
247
 
  va_list ap;
248
 
  va_start(ap, firstObject);
249
 
  self = [self initWithObjects: firstObject rest: ap];
250
 
  va_end(ap);
 
355
  GS_USEIDLIST(firstObject,
 
356
    self = [self initWithObjects: __objects count: __count]);
251
357
  return self;
252
358
}
253
359
 
254
 
/* Override superclass's designated initializer */
255
 
- (id) init
256
 
{
257
 
  return [self initWithObjects: NULL count: 0];
258
 
}
259
 
 
 
360
/**
 
361
 * Initialises a newly allocated set by adding all the objects
 
362
 * in the supplied array to the set.
 
363
 */
260
364
- (id) initWithArray: (NSArray*)other
261
365
{
262
366
  unsigned      count = [other count];
267
371
    }
268
372
  else
269
373
    {
270
 
      id        objs[count];
 
374
      GS_BEGINIDBUF(objs, count);
271
375
 
272
376
      [other getObjects: objs];
273
 
      return [self initWithObjects: objs count: count];
 
377
      self = [self initWithObjects: objs count: count];
 
378
      GS_ENDIDBUF();
 
379
      return self;
274
380
    }
275
381
}
276
382
 
 
383
/**
 
384
 * Initialises a newly allocated set by adding all the objects
 
385
 * in the supplied set.
 
386
 */
277
387
- (id) initWithSet: (NSSet*)other copyItems: (BOOL)flag
278
388
{
279
389
  unsigned      c = [other count];
280
 
  id            os[c], o, e = [other objectEnumerator];
 
390
  id            o, e = [other objectEnumerator];
281
391
  unsigned      i = 0;
 
392
  GS_BEGINIDBUF(os, c);
282
393
 
283
394
  while ((o = [e nextObject]))
284
395
    {
294
405
    while (i--)
295
406
      [os[i] release];
296
407
#endif
 
408
  GS_ENDIDBUF();
297
409
  return self;
298
410
}
299
411
 
300
 
- (id) initWithSet: (NSSet*)other 
 
412
/**
 
413
 *  Initialize with same items as other (items not copied).
 
414
 */
 
415
- (id) initWithSet: (NSSet*)other
301
416
{
302
417
  return [self initWithSet: other copyItems: NO];
303
418
}
304
419
 
 
420
/**
 
421
 *  Return array of all objects in set.  Order is undefined.
 
422
 */
305
423
- (NSArray*) allObjects
306
424
{
307
425
  id            e = [self objectEnumerator];
308
 
  unsigned      i, c = [self count];
309
 
  id            k[c];
 
426
  unsigned      i;
 
427
  unsigned      c = [self count];
 
428
  NSArray       *result;
 
429
  GS_BEGINIDBUF(k, c);
310
430
 
311
431
  for (i = 0; i < c; i++)
312
432
    {
314
434
    }
315
435
  return AUTORELEASE([[NSArray allocWithZone: NSDefaultMallocZone()]
316
436
    initWithObjects: k count: c]);
 
437
  GS_ENDIDBUF();
 
438
  return result;
317
439
}
318
440
 
 
441
/**
 
442
 *  Return an arbitrary object from set, or nil if this is empty set.
 
443
 */
319
444
- (id) anyObject
320
445
{
321
446
  if ([self count] == 0)
327
452
    }
328
453
}
329
454
 
 
455
/**
 
456
 *  Return whether set contains an object equal to this one according
 
457
 *  to [NSObject-isEqual:].
 
458
 */
330
459
- (BOOL) containsObject: (id)anObject
331
460
{
332
461
  return (([self member: anObject]) ? YES : NO);
337
466
  return [self count];
338
467
}
339
468
 
 
469
/**
 
470
 *  Send each object given message (with no arguments).
 
471
 *  Identical to [-makeObjectsPerformSelector:].
 
472
 */
340
473
- (void) makeObjectsPerform: (SEL)aSelector
341
474
{
342
475
  id    o, e = [self objectEnumerator];
345
478
    [o performSelector: aSelector];
346
479
}
347
480
 
 
481
/**
 
482
 *  Send each object given message (with no arguments).
 
483
 *  Identical to [-makeObjectsPerform:].
 
484
 */
348
485
- (void) makeObjectsPerformSelector: (SEL)aSelector
349
486
{
350
487
  id    o, e = [self objectEnumerator];
353
490
    [o performSelector: aSelector];
354
491
}
355
492
 
 
493
/**
 
494
 *  Send each object given message with given argument.
 
495
 *  Identical to [-makeObjectsPerform:withObject:].
 
496
 */
356
497
- (void) makeObjectsPerformSelector: (SEL)aSelector withObject: argument
357
498
{
358
499
  id    o, e = [self objectEnumerator];
361
502
    [o performSelector: aSelector withObject: argument];
362
503
}
363
504
 
 
505
/**
 
506
 *  Send each object given message with given argument.
 
507
 *  Identical to [-makeObjectsPerformSelector:withObject:].
 
508
 */
364
509
- (void) makeObjectsPerform: (SEL)aSelector withObject: argument
365
510
{
366
511
  id    o, e = [self objectEnumerator];
369
514
    [o performSelector: aSelector withObject: argument];
370
515
}
371
516
 
 
517
/**
 
518
 *  Return whether set intersection with otherSet is non-empty.
 
519
 */
372
520
- (BOOL) intersectsSet: (NSSet*) otherSet
373
521
{
374
522
  id    o = nil, e = nil;
387
535
  return NO;
388
536
}
389
537
 
 
538
/**
 
539
 *  Return whether subset of otherSet.
 
540
 */
390
541
- (BOOL) isSubsetOfSet: (NSSet*) otherSet
391
542
{
392
543
  id o = nil, e = nil;
422
573
  return NO;
423
574
}
424
575
 
 
576
/**
 
577
 *  Return whether each set is subset of the other.
 
578
 */
425
579
- (BOOL) isEqualToSet: (NSSet*)other
426
580
{
427
581
  if ([self count] != [other count])
438
592
  return YES;
439
593
}
440
594
 
 
595
/**
 
596
 *  Returns listing of objects in set.
 
597
 */
441
598
- (NSString*) description
442
599
{
443
600
  return [self descriptionWithLocale: nil];
444
601
}
445
602
 
 
603
/**
 
604
 *  Returns listing of objects in set.
 
605
 */
446
606
- (NSString*) descriptionWithLocale: (NSDictionary*)locale
447
607
{
448
608
  return [[self allObjects] descriptionWithLocale: locale];
450
610
 
451
611
@end
452
612
 
 
613
 
 
614
/**
 
615
 *  Mutable version of [NSSet].
 
616
 */
453
617
@implementation NSMutableSet
454
618
 
455
619
+ (void) initialize
459
623
    }
460
624
}
461
625
 
 
626
/**
 
627
 *  New autoreleased instance with given capacity.
 
628
 */
462
629
+ (id) setWithCapacity: (unsigned)numItems
463
630
{
464
631
  return AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()]
482
649
  return NSMutableSet_concrete_class;
483
650
}
484
651
 
485
 
- (id) copyWithZone: (NSZone*)z
486
 
{
487
 
  return [[NSSet_concrete_class allocWithZone: z] initWithSet: self];
488
 
}
489
 
 
490
 
/* This is the designated initializer */
 
652
/** <init /> <override-subclass />
 
653
 * Initialises a newly allocated set to contain no objects but
 
654
 * to have space available to hold the specified number of items.<br />
 
655
 * Additions of items to a set initialised
 
656
 * with an appropriate capacity will be more efficient than addition
 
657
 * of items otherwise.<br />
 
658
 * Calls -init (which does nothing but maintain MacOS-X compatibility),
 
659
 * and needs to be re-implemented in subclasses in order to have all
 
660
 * other initialisers work.
 
661
 */
491
662
- (id) initWithCapacity: (unsigned)numItems
492
663
{
493
 
  return [self subclassResponsibility: _cmd];
 
664
  self = [self init];
 
665
  return self;
494
666
}
495
667
 
 
668
/**
 
669
 * Adds anObject to the set.<br />
 
670
 * The object is retained by the set.
 
671
 */
496
672
- (void) addObject: (id)anObject
497
673
{
498
674
  [self subclassResponsibility: _cmd];
499
675
}
500
676
 
 
677
/**
 
678
 * Removes the anObject from the receiver.
 
679
 */
501
680
- (void) removeObject: (id)anObject
502
681
{
503
682
  [self subclassResponsibility: _cmd];
517
696
  return self;
518
697
}
519
698
 
 
699
/**
 
700
 * Adds all the objects in the array to the receiver.
 
701
 */
520
702
- (void) addObjectsFromArray: (NSArray*)array
521
703
{
522
704
  unsigned      i, c = [array count];
527
709
    }
528
710
}
529
711
 
 
712
/**
 
713
 * Removes from the receiver all the objects it contains
 
714
 * which are not also in other.
 
715
 */
530
716
- (void) intersectSet: (NSSet*) other
531
717
{
532
718
  if (other != self)
544
730
    }
545
731
}
546
732
 
 
733
/**
 
734
 * Removes from the receiver all the objects that are in
 
735
 * other.
 
736
 */
547
737
- (void) minusSet: (NSSet*) other
548
738
{
549
739
  if (other == self)
562
752
    }
563
753
}
564
754
 
 
755
/**
 
756
 * Removes all objects from the receiver.
 
757
 */
565
758
- (void) removeAllObjects
566
759
{
567
760
  [self subclassResponsibility: _cmd];
568
761
}
569
762
 
 
763
/**
 
764
 * Removes all objects from the receiver then adds the
 
765
 * objects from other.  If the receiver <em>is</em>
 
766
 * other, the method has no effect.
 
767
 */
570
768
- (void) setSet: (NSSet*)other
571
769
{
572
770
  if (other == self)
587
785
    }
588
786
}
589
787
 
 
788
/**
 
789
 
 
790
 * Adds all the objects from other to the receiver.
 
791
 */
590
792
- (void) unionSet: (NSSet*) other
591
793
{
592
794
  if (other != self)