mirror of
https://github.com/apple/swift-collections
synced 2026-11-30 05:18:44 +00:00
[BasicContainers] Add a containsKey method to dictionaries
This commit is contained in:
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)
|
||||
|
||||
Reference in new issue
Block a user