NSCountedSet Mac OS X 10.0

This class extends the functionality of NSMutableSet by associating with each member of the set a count of how many times the object has been added to the set. By keeping a count with each object, NSCountedSet essentially removes the restriction that every member of a set must be unique. NSCountedSet reimplements several of NSMutableSet's methods to support the object counter. The one new method in NSCountedSet is countForObject:, which will return the counter value for the specified object. If the object is not a member of the set, this method returns 0. This count can be viewed as the number of occurences of the object within the set.


@interface NSCountedSet : NSMutableSet
 // Initializers
   - (id)initWithArray:(NSArray *)array;
   - (id)initWithCapacity:(unsigned)numItems;
   - (id)initWithSet:(NSSet *)set;
 // Instance Methods
   - (void)addObject:(id)object;
   - (unsigned)countForObject:(id)object;
   - (NSEnumerator *)objectEnumerator;
   - (void)removeObject:(id)object;

    Part II: API Quick Reference
    Chapter 13. Foundation Classes