Class: NSCountedSet
- Inherits:
-
NSMutableSet
- Object
- NSObject
- NSSet
- NSMutableSet
- NSCountedSet
Overview
The NSCountedSet class declares the programmatic interface to a mutable, unordered collection of indistinct objects. A counted set is also known as a bag.
Instance Method Summary (collapse)
-
- addObject:
Adds a given object to the set.
-
- countForObject:
Returns the count associated with a given object in the set.
-
- initWithArray:
Returns a counted set object initialized with the contents of a given array.
-
- initWithCapacity:
Returns a counted set object initialized with enough memory to hold a given number of objects.
-
- initWithSet:
Returns a counted set object initialized with the contents of a given set.
-
- objectEnumerator
Returns an enumerator object that lets you access each object in the set once, independent of its count.
-
- removeObject:
Removes a given object from the set.
Methods inherited from NSMutableSet
#addObjectsFromArray:, #filterUsingPredicate:, #intersectSet:, #minusSet:, #removeAllObjects, #setSet:, setWithCapacity:, #unionSet:
Methods inherited from NSSet
#addObserver:forKeyPath:options:context:, #allObjects, #anyObject, #containsObject:, #count, #description, #descriptionWithLocale:, #enumerateObjectsUsingBlock:, #enumerateObjectsWithOptions:usingBlock:, #filteredSetUsingPredicate:, #initWithObjects:, #initWithObjects:count:, #initWithSet:copyItems:, #intersectsSet:, #isEqualToSet:, #isSubsetOfSet:, #makeObjectsPerformSelector:, #makeObjectsPerformSelector:withObject:, #member:, #objectsPassingTest:, #objectsWithOptions:passingTest:, #removeObserver:forKeyPath:, set, #setByAddingObject:, #setByAddingObjectsFromArray:, #setByAddingObjectsFromSet:, #setValue:forKey:, setWithArray:, setWithObject:, setWithObjects:, setWithObjects:count:, setWithSet:, #sortedArrayUsingDescriptors:, #valueForKey:
Methods inherited from NSObject
#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version
Constructor Details
This class inherits a constructor from NSObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class NSObject
Instance Method Details
- (Object) addObject(anObject)
Adds a given object to the set. If anObject is already a member, addObject: increments the count associated with the object. If anObject is not already a member, it is sent a retain message.
- (Integer) countForObject(anObject)
Returns the count associated with a given object in the set.
- (Object) initWithArray(anArray)
Returns a counted set object initialized with the contents of a given array.
- (Object) initWithCapacity(numItems)
Returns a counted set object initialized with enough memory to hold a given number of objects. The method is the designated initializer for NSCountedSet.Note that the capacity is simply a hint to help initial memory allocation—the initial count of the object is 0, and the set still grows and shrinks as you add and remove objects. The hint is typically useful if the set will become large.
- (Object) initWithSet(aSet)
Returns a counted set object initialized with the contents of a given set.
- (NSEnumerator) objectEnumerator
Returns an enumerator object that lets you access each object in the set once, independent of its count. If you add a given object to the counted set multiple times, an enumeration of the set will produce that object only once.You shouldn’t modify the set during enumeration. If you intend to modify the set, use the allObjects method to create a “snapshot,” then enumerate the snapshot and modify the original set.
- (Object) removeObject(anObject)
Removes a given object from the set. If anObject is present in the set, decrements the count associated with it. If the count is decremented to 0, anObject is removed from the set and sent a release message. removeObject: does nothing if anObject is not present in the set.