Class: NSHashTable

Inherits:
NSObject show all

Overview

NSHashTable is modeled after NSSet but provides different options, in particular to support weak relationships.

Class Method Summary (collapse)

Instance Method Summary (collapse)

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

Class Method Details

+ (Object) hashTableWithOptions(options)

Returns a hash table with given pointer functions options.

Parameters:

  • options (NSPointerFunctionsOptions)

    A bit field that specifies the options for the elements in the hash table. For possible values, see “Hash Table Options”.

Returns:

  • (Object)

    A hash table with given pointer functions options.

+ (Object) weakObjectsHashTable

Returns a new hash table for storing weak references to its contents.

Returns:

  • (Object)

    A new has table that uses the options NSHashTableZeroingWeakMemory and NSPointerFunctionsObjectPersonality and has an initial capacity of 0.

Instance Method Details

- (Object) addObject(object)

Adds a given object to the hash table.

Parameters:

  • object (Object)

    The object to add to the hash table.

Returns:

- (Array) allObjects

Returns an array that contains the hash table’s members.

Returns:

  • (Array)

    An array that contains the hash table’s members.

- (Object) anyObject

Returns one of the objects in the hash table. The object returned is chosen at the hash table’s convenience—the selection is not guaranteed to be random.

Returns:

  • (Object)

    One of the objects in the hash table, or nil if the hash table contains no objects.

- (Boolean) containsObject(anObject)

Returns a Boolean value that indicates whether the hash table contains a given object. The equality test used depends on the personality option selected. For instance, choosing the NSPointerFunctionsObjectPersonality option will use isEqual: to determine equality. See NSPointerFunctionsOptions for more information on personality options and their corresponding equality tests.

Parameters:

  • anObject (Object)

    The object to test for membership in the hash table.

Returns:

  • (Boolean)

    YES if the hash table contains anObject, otherwise NO.

- (Integer) count

Returns the number of elements in the hash table.

Returns:

  • (Integer)

    The number of elements in the hash table.

- (Object) initWithOptions(options, capacity:capacity)

Returns a hash table initialized with the given attributes.

Parameters:

  • options (NSPointerFunctionsOptions)

    A bit field that specifies the options for the elements in the hash table. For possible values, see “Hash Table Options”.

  • capacity (Integer)

    The initial number of elements the hash table can hold.

Returns:

  • (Object)

    A hash table initialized with options specified by options and initial capacity of capacity.

- (Object) initWithPointerFunctions(functions, capacity:initialCapacity)

Returns a hash table initialized with the given functions and capacity. Hash tables allocate additional memory as needed, so initialCapacity simply establishes the object’s initial capacity.

Parameters:

  • functions (NSPointerFunctions)

    The pointer functions for the new hash table.

  • initialCapacity (Integer)

    The initial capacity of the hash table.

Returns:

  • (Object)

    A hash table initialized with the given functions and capacity.

- (Object) intersectHashTable(other)

Removes from the receiving hash table each element that isn’t a member of another given hash table. The equality test used for members depends on the personality option selected. For instance, choosing the NSPointerFunctionsObjectPersonality option will use isEqual: to determine equality. See NSPointerFunctionsOptions for more information on personality options and their corresponding equality tests.

Parameters:

  • other (NSHashTable)

    The hash table with which to perform the intersection.

Returns:

- (Boolean) intersectsHashTable(other)

Returns a Boolean value that indicates whether a given hash table intersects with the receiving hash table. The equality test used for members depends on the personality option selected. For instance, choosing the NSPointerFunctionsObjectPersonality option will use isEqual: to determine equality. See NSPointerFunctionsOptions for more information on personality options and their corresponding equality tests.

Parameters:

  • other (NSHashTable)

    The hash table with which to compare the receiving hash table.

Returns:

  • (Boolean)

    YES if other intersects with the receiving hash table, otherwise NO.

- (Boolean) isEqualToHashTable(other)

Returns a Boolean value that indicates whether a given hash table is equal to the receiving hash table. Two hash tables have equal contents if they each have the same number of members and if each member of one hash table is present in the other.The equality test used for members depends on the personality option selected. For instance, choosing the NSPointerFunctionsObjectPersonality option will use isEqual: to determine equality. See NSPointerFunctionsOptions for more information on personality options and their corresponding equality tests.

Parameters:

  • other (NSHashTable)

    The hash table with which to compare the receiving hash table.

Returns:

  • (Boolean)

    YES if the contents of other are equal to the contents of the receiving hash table, otherwise NO.

- (Boolean) isSubsetOfHashTable(other)

Returns a Boolean value that indicates whether every element in the receiving hash table is also present in another given hash table. The equality test used for members depends on the personality option selected. For instance, choosing the NSPointerFunctionsObjectPersonality option will use isEqual: to determine equality. See NSPointerFunctionsOptions for more information on personality options and their corresponding equality tests.

Parameters:

  • other (NSHashTable)

    The hash table with which to compare the receiving hash table.

Returns:

  • (Boolean)

    YES if every element in the receiving hash table is also present in other, otherwise NO.

- (Object) member(object)

Determines whether the hash table contains a given object, and returns that object if it is present The equality test used depends on the personality option selected. For instance, choosing the NSPointerFunctionsObjectPersonality option will use isEqual: to determine equality. See NSPointerFunctionsOptions for more information on personality options and their corresponding equality tests.

Parameters:

  • object (Object)

    The object to test for membership in the hash table.

Returns:

  • (Object)

    If object is a member of the hash table, returns object, otherwise returns nil.

- (Object) minusHashTable(other)

Removes each element in another given hash table from the receiving hash table, if present. The equality test used for members depends on the personality option selected. For instance, choosing the NSPointerFunctionsObjectPersonality option will use isEqual: to determine equality. See NSPointerFunctionsOptions for more information on personality options and their corresponding equality tests.

Parameters:

  • other (NSHashTable)

    The hash table of elements to remove from the receiving hash table.

Returns:

- (NSEnumerator) objectEnumerator

Returns an enumerator object that lets you access each object in the hash table. The following code fragment illustrates how you can use this method.

Returns:

  • (NSEnumerator)

    An enumerator object that lets you access each object in the hash table.

- (NSPointerFunctions) pointerFunctions

Returns the pointer functions for the hash table.

Returns:

- (Object) removeAllObjects

Removes all objects from the hash table.

Returns:

- (Object) removeObject(object)

Removes a given object from the hash table.

Parameters:

  • object (Object)

    The object to remove from the hash table.

Returns:

- (NSSet) setRepresentation

Returns a set that contains the hash table’s members.

Returns:

  • (NSSet)

    A set that contains the hash table’s members.

- (Object) unionHashTable(other)

Adds each element in another given hash table to the receiving hash table, if not present. The equality test used for members depends on the personality option selected. For instance, choosing the NSPointerFunctionsObjectPersonality option will use isEqual: to determine equality. See NSPointerFunctionsOptions for more information on personality options and their corresponding equality tests.

Parameters:

  • other (NSHashTable)

    The hash table of elements to add to the receiving hash table.

Returns: