[BasicContainers] Add a containsKey method to dictionaries

This commit is contained in:
Karoy Lorentey committed 2026-02-23 13:58:56 -08:00
1 parent 992bff5b87
commit 8624f936ea
2 files changed
+10

No files matched your search

@@ -24,6 +24,11 @@ extension RigidDictionary where Key: ~Copyable, Value: ~Copyable {
) -> (bucket: _Bucket?, hashValue: Int) {
self._keys._find(key)
}
@inlinable
public func containsKey(_ key: borrowing Key) -> Bool {
_find(key).bucket != nil
}
#if COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
@inlinable
@@ -17,6 +17,11 @@ import ContainersPreview
@available(SwiftStdlib 5.0, *)
extension UniqueDictionary where Key: ~Copyable, Value: ~Copyable {
@inlinable
public func containsKey(_ key: borrowing Key) -> Bool {
_storage.containsKey(key)
}
#if COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
@inlinable
@_lifetime(borrow self)