Inherits from | |
Conforms to | |
Framework | /System/Library/Frameworks/Foundation.framework |
Availability | Available in Mac OS X v10.5 and later. |
Companion guide | |
Declared in | NSHashTable.h |
NSHashTable
is modeled after NSSet
but provides different options, in particular to support weak relationships in a garbage-collected environment.
Returns a hash table with given pointer functions options.
+ (id)hashTableWithOptions:(NSPointerFunctionsOptions)options
A bit field that specifies the options for the elements in the hash table. For possible values, see “Hash Table Options”
.
A hash table with given pointer functions options.
NSHashTable.h
Returns a new hash table for storing weak references to its contents.
+ (id)hashTableWithWeakObjects
A new has table that uses the options NSHashTableZeroingWeakMemory
and NSPointerFunctionsObjectPersonality
and has an initial capacity of 0
.
NSHashTable.h
Adds a given object to the receiver.
- (void)addObject:(id)object
The object to add to the receiver.
NSHashTable.h
Returns an array that contains the receiver’s members.
- (NSArray *)allObjects
An array that contains the receiver’s members.
NSHashTable.h
Returns one of the objects in the receiver.
- (id)anyObject
One of the objects in the receiver, or nil
if the receiver contains no objects.
The object returned is chosen at the receiver’s convenience—the selection is not guaranteed to be random.
NSHashTable.h
Returns a Boolean value that indicates whether the receiver contains a given object.
- (BOOL)containsObject:(id)anObject
The object to test for membership in the receiver.
YES
if the receiver contains anObject, otherwise NO
.
NSHashTable.h
Returns the number of elements in the receiver.
- (NSUInteger)count
The number of elements in the receiver.
NSHashTable.h
Returns a hash table initialized with the given attributes.
- (id)initWithOptions:(NSPointerFunctionsOptions)options capacity:(NSUInteger)capacity
A bit field that specifies the options for the elements in the hash table. For possible values, see “Hash Table Options”
.
The initial number of elements the receiver can hold.
A hash table initialized with options specified by options and initial capacity of capacity.
NSHashTable.h
Returns a hash table initialized with the given functions and capacity.
- (id)initWithPointerFunctions:(NSPointerFunctions *)functions capacity:(NSUInteger)initialCapacity
The pointer functions for the new hash table.
The initial capacity of the hash table.
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.
NSHashTable.h
Returns a Boolean value that indicates whether at least one element in the receiver is also present in another given hash table.
- (void)intersectHashTable:(NSHashTable *)other
The hash table with which to compare the receiver.
NSHashTable.h
Returns a Boolean value that indicates whether a given hash table intersects with the receiver.
- (BOOL)intersectsHashTable:(NSHashTable *)other
The hash table with which to compare the receiver.
YES
if other intersects with the receiver, otherwise NO
.
NSHashTable.h
Returns a Boolean value that indicates whether a given hash table is equal to the receiver.
- (BOOL)isEqualToHashTable:(NSHashTable *)other
The hash table with which to compare the receiver.
YES
if the contents of other are equal to the contents of the receiver, otherwise NO
.
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.
NSHashTable.h
Returns a Boolean value that indicates whether every element in the receiver is also present in another given hash table.
- (BOOL)isSubsetOfHashTable:(NSHashTable *)other
The hash table with which to compare the receiver.
YES
if every element in the receiver is also present in other, otherwise NO
.
NSHashTable.h
Determines whether a given object is an element in the receiver.
- (id)member:(id)object
The object to test for membership in the receiver.
If object is a member of the receiver, returns object, otherwise returns nil
.
NSHashTable.h
Removes from the receiver each element contained in another given hash table that is present in the receiver.
- (void)minusHashTable:(NSHashTable *)other
The hash table of elements to remove from the receiver.
If any element of other isn’t present in the receiver, this method has no effect on either the receiver or other.
NSHashTable.h
Returns an enumerator object that lets you access each object in the receiver.
- (NSEnumerator *)objectEnumerator
An enumerator object that lets you access each object in the receiver.
The following code fragment illustrates how you can use this method.
NSEnumerator *enumerator = [myHashTable objectEnumerator]; |
id value; |
while ((value = [enumerator nextObject])) { |
/* code that acts on the hash table's values */ |
} |
Note that NSHashTable
also supports the NSFastEnumeration
protocol.
NSHashTable.h
Returns the pointer functions for the receiver.
- (NSPointerFunctions *)pointerFunctions
The pointer functions for the receiver.
NSHashTable.h
Removes all objects from the receiver.
- (void)removeAllObjects
NSHashTable.h
Removes a given object from the receiver.
- (void)removeObject:(id)object
The object to remove from the receiver.
NSHashTable.h
Returns a set that contains the receiver’s members.
- (NSSet *)setRepresentation
A set that contains the receiver’s members.
NSHashTable.h
Adds to the receiver each element contained in another given hash table that is not already a member.
- (void)unionHashTable:(NSHashTable *)other
The hash table of elements to add to the receiver.
NSHashTable.h
Type to specify a bit-field used to define the behavior of elements in an NSHashTable
object.
typedef NSUInteger NSHashTableOptions;
For possible values, see “Hash Table Options.”
NSHashTable.h
Components in a bit-field to specify the behavior of elements in an NSHashTable
object.
enum { NSHashTableStrongMemory = 0, NSHashTableZeroingWeakMemory = NSPointerFunctionsZeroingWeakMemory, NSHashTableCopyIn = NSPointerFunctionsCopyIn, NSHashTableObjectPointerPersonality = NSPointerFunctionsObjectPointerPersonality, };
NSHashTableStrongMemory
Equal to NSPointerFunctionsStrongMemory
.
Available in Mac OS X v10.5 and later.
Declared in NSHashTable.h
.
NSHashTableZeroingWeakMemory
Equal to NSPointerFunctionsZeroingWeakMemory
.
Available in Mac OS X v10.5 and later.
Declared in NSHashTable.h
.
NSHashTableCopyIn
Equal to NSPointerFunctionsCopyIn
.
Available in Mac OS X v10.5 and later.
Declared in NSHashTable.h
.
NSHashTableObjectPointerPersonality
Equal to NSPointerFunctionsObjectPointerPersonality
.
Available in Mac OS X v10.5 and later.
Declared in NSHashTable.h
.
NSHashTable.h
© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-06-26)