<!--
{
  "documentType" : "article",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/legacy-hash-table-implementation",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Legacy Hash Table Implementation"
}
-->

# Legacy Hash Table Implementation

## Topics

### Functions

[`func NSAllHashTableObjects(NSHashTable<AnyObject>) -> [Any]`](/documentation/Foundation/NSAllHashTableObjects(_:))

Returns all of the elements in the specified hash table.

[`func NSCompareHashTables(NSHashTable<AnyObject>, NSHashTable<AnyObject>) -> Bool`](/documentation/Foundation/NSCompareHashTables(_:_:))

Returns a Boolean value that indicates whether the elements of two hash tables are equal.

[`func NSCopyHashTableWithZone(NSHashTable<AnyObject>, NSZone?) -> NSHashTable<AnyObject>`](/documentation/Foundation/NSCopyHashTableWithZone(_:_:))

Performs a shallow copy of the specified hash table.

[`func NSCountHashTable(NSHashTable<AnyObject>) -> Int`](/documentation/Foundation/NSCountHashTable(_:))

Returns the number of elements in a hash table.

[`func NSCreateHashTable(NSHashTableCallBacks, Int) -> NSHashTable<AnyObject>`](/documentation/Foundation/NSCreateHashTable(_:_:))

Creates and returns a new hash table.

[`func NSCreateHashTableWithZone(NSHashTableCallBacks, Int, NSZone?) -> NSHashTable<AnyObject>`](/documentation/Foundation/NSCreateHashTableWithZone(_:_:_:))

Creates a new hash table in a given zone.

[`func NSEndHashTableEnumeration(UnsafeMutablePointer<NSHashEnumerator>)`](/documentation/Foundation/NSEndHashTableEnumeration(_:))

Used when finished with an enumerator.

[`func NSEnumerateHashTable(NSHashTable<AnyObject>) -> NSHashEnumerator`](/documentation/Foundation/NSEnumerateHashTable(_:))

Creates an enumerator for the specified hash table.

[`func NSFreeHashTable(NSHashTable<AnyObject>)`](/documentation/Foundation/NSFreeHashTable(_:))

Deletes the specified hash table.

[`func NSHashGet(NSHashTable<AnyObject>, UnsafeRawPointer?) -> UnsafeMutableRawPointer`](/documentation/Foundation/NSHashGet(_:_:))

Returns an element of the hash table.

[`func NSHashInsert(NSHashTable<AnyObject>, UnsafeRawPointer?)`](/documentation/Foundation/NSHashInsert(_:_:))

Adds an element to the specified hash table.

[`func NSHashInsertIfAbsent(NSHashTable<AnyObject>, UnsafeRawPointer?) -> UnsafeMutableRawPointer?`](/documentation/Foundation/NSHashInsertIfAbsent(_:_:))

Adds an element to the specified hash table only if the table does not already contain the element.

[`func NSHashInsertKnownAbsent(NSHashTable<AnyObject>, UnsafeRawPointer?)`](/documentation/Foundation/NSHashInsertKnownAbsent(_:_:))

Adds an element to the specified hash table.

[`func NSHashRemove(NSHashTable<AnyObject>, UnsafeRawPointer?)`](/documentation/Foundation/NSHashRemove(_:_:))

Removes an element from the specified hash table.

[`func NSNextHashEnumeratorItem(UnsafeMutablePointer<NSHashEnumerator>) -> UnsafeMutableRawPointer?`](/documentation/Foundation/NSNextHashEnumeratorItem(_:))

Returns the next hash-table element in the enumeration.

[`func NSResetHashTable(NSHashTable<AnyObject>)`](/documentation/Foundation/NSResetHashTable(_:))

Deletes the elements of the specified hash table.

[`func NSStringFromHashTable(NSHashTable<AnyObject>) -> String`](/documentation/Foundation/NSStringFromHashTable(_:))

Returns a string describing the hash table’s contents.

### Data Types

[`struct NSHashEnumerator`](/documentation/Foundation/NSHashEnumerator)

Allows successive elements of a hash table to be returned each time this structure is passed to [`NSNextHashEnumeratorItem(_:)`](/documentation/Foundation/NSNextHashEnumeratorItem(_:)).

[`struct NSHashTableCallBacks`](/documentation/Foundation/NSHashTableCallBacks)

Defines a structure that contains the function pointers used to configure behavior of `NSHashTable` with respect to elements within a hash table.

[`typealias NSHashTableOptions`](/documentation/Foundation/NSHashTableOptions)

Components in a bit-field to specify the behavior of elements in an [`NSHashTable`](/documentation/Foundation/NSHashTable) object.

### Constants

[`let NSIntegerHashCallBacks: NSHashTableCallBacks`](/documentation/Foundation/NSIntegerHashCallBacks)

For sets of `NSInteger`-sized quantities or smaller (for example, `int`, `long`, or `unichar`).

[`extern const NSHashTableCallBacks NSIntHashCallBacks;`](/documentation/Foundation/NSIntHashCallBacks)

For sets of pointer-sized quantities or smaller (for example, `int`, `long`, or `unichar`).

[`let NSNonOwnedPointerHashCallBacks: NSHashTableCallBacks`](/documentation/Foundation/NSNonOwnedPointerHashCallBacks)

For sets of pointers, hashed by address.

[`let NSNonRetainedObjectHashCallBacks: NSHashTableCallBacks`](/documentation/Foundation/NSNonRetainedObjectHashCallBacks)

For sets of objects, but without retaining/releasing.

[`let NSObjectHashCallBacks: NSHashTableCallBacks`](/documentation/Foundation/NSObjectHashCallBacks)

For sets of objects (similar to `NSSet`).

[`let NSOwnedObjectIdentityHashCallBacks: NSHashTableCallBacks`](/documentation/Foundation/NSOwnedObjectIdentityHashCallBacks)

For sets of objects, with transfer of ownership upon insertion, using pointer equality.

[`let NSOwnedPointerHashCallBacks: NSHashTableCallBacks`](/documentation/Foundation/NSOwnedPointerHashCallBacks)

For sets of pointers, with transfer of ownership upon insertion.

[`let NSPointerToStructHashCallBacks: NSHashTableCallBacks`](/documentation/Foundation/NSPointerToStructHashCallBacks)

For sets of pointers to structs, when the first field of the struct is `int`-sized.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)