This is NSCountedSet.rtf in view mode; [Download] [Up]
paperh18648 margl-907 margr0 margt0 margb0 fi0 ri0 ql sb0 f1 fs24 Copyright f3 'e3f1 1994 by NeXT Computer, Inc. All Rights Reserved. s4 li100 fi0 ri1007 ql f0 b fs36 fs100 fs36 NSCountedSet pard s11 li2872 fi-2771 ri1007 ql tx2872 f1 b0 fs28 fs48 fs28 f0 b fs24 Inherits From:tab b0 fs28 f1 NSMutableSet : NSSet : NSObject fs20 fs28 s6 f0 b fs24 Conforms To:tab b0 fs28 f1 NSCoding, NSCopying, NSMutableCopying (NSSet) fi0 NSObject (NSObject) fs20 fs28 s7 fi-2771 f0 b fs24 Declared In:tab b0 fs28 f1 Foundation/NSSet.h fs20 fs28 pard s16 li100 fi0 ri1007 ql f0 b fs28 fs20 fs28 Class Description fs14 fs28 pard s1 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 f1 b0 fs2 fs28 The NSCountedSet class declares the programmatic interface to an object that manages a mutable set of objects. NSCountedSet provides support for the mathematical concept of a i counted seti0 . A counted set, both in its mathematical sense and in the OpenStep implementation of NSCountedSet, is an unordered collection of elements, just as in a regular set, but the elements of the set aren'27t necessarily distinct. In the literature, a counted set is also knownas a i bagi0 . fs16 fs28 Each new'd0that is, distinct'd0object inserted into an NSCountedSet object has a counter associated with it. NSCountedSet keeps track of the number of times objects are inserted and requires that objects are removed the same number of times. OpenStep also provides the NSSet class for sets whose elements i arei0 distinct'd0that is, there is only one instance of an object in an NSSet even if the object has been added to the set multiple times. fs16 fs28 Use set objects as an alternative to array objects when the order of elements is not important, but performance in testing whether an object is contained in the set i isi0 a consideration'd0while arrays are ordered, testing for membership is slower than with sets. fs16 fs28 Objects in a set must respond to b hashb0 and b isEqual:b0 methods. See the NSObject protocol for details on b hashb0 and b isEqual:b0 . Each new distinct object must provide a unique hash value. fs16 fs28 Generally, you instantiate an NSCountedSet object by sending one of the b set'bcb0 methods to the NSCountedSet class object, as described in NSSet. These methods return an NSCountedSet object containing the elements (if any) you pass in as arguments. Newly created instances of NSCountedSet created by invoking the b setb0 method can be populated with objects using any of the b init'bcb0 methods. b initWithObjects::b0 is the designated initializer for this class. fs16 fs28 pard s8 li7029 fi-6552 ri1007 ql tx6652 tx7030 You add or remove objects from a counted set using the b addObject:b0 and b removeObject:b0 methods. pard s1 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 fs16 fs28 An NSCountedSet may be queried using the b objectEnumeratorb0 method, which provides for traversing elements of the set one by one. The b countForObject: b0 method returns the number of times the specified object has been added to this setb . fs16 fs28 pard s16 li100 fi0 ri1007 ql f0 fs24 fs28 Initializing an NSCountedSet fs14 fs28 pard s8 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 fs28 fi-6552 {f3 -} (id)b initWithArray:b0 (NSArray *)i anArrayi0 tab Initializes a newly allocated set object by placing in it the objects contained in i anArray. fi-6552 i0 fs16 fs28 fi-6552 {f3 -} (id)b initWithCapacity:b0 (unsigned int)i numItemsi0 tab Initializes a newly allocated set object, giving it enough memory to hold i numItemsi0 objects. fi-6552 fs16 fs28 fi-6552 {f3 -} (id)b initWithSet:b0 (NSSet *)i anotherSeti0 tab Initializes a newly allocated set object by placing in it the objects contained in i anotherSet. pard s16 li100 fi0 ri1007 ql f0 b i0 fs48 fs28 Adding Objectstab fs14 fs28 pard s8 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 fs28 fi-6552 {f3 -} (void)b addObject:b0 (id)i anObjecti0 tab Adds i anObjecti0 to the set, unless i anObject i0 is equal to some object already in the set. In either case, the counter that'27s returned by b countForObject:b0 is incremented. pard s16 li100 fi0 ri1007 ql f0 b fs48 fs28 Removing Objects fs14 fs28 pard s8 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 fs28 fi-6552 {f3 -} (void)b removeObject:b0 (id)i anObjecti0 tab Decrements the counter for the object, if the set contains an object that'27s equal to i anObjecti0 . If this causes the counter to reach zero, the object that'27s equal to i anObjecti0 is removed from the set. pard s16 li100 fi0 ri1007 ql f0 b fs48 fs28 Querying the NSCountedSet fs14 fs28 pard s8 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 fs28 fi-6552 {f3 -} (unsigned int)b countForObject:b0 (id)i anObjecti0 tab Returns the number of times that an object equal to i anObjecti0 has ostensibly been added to the set. (This number is incremented by b addObject: b0 and decremented by b removeObject:b0 .) fi-6552 fs16 fs28 fi-6552 {f3 -} (NSEnumerator *)b objectEnumeratorb0 tab Returns an enumerator object that will access each object in the set only once, regardless of its count. fi-6552 fs16 fs28 fi-6552 }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.