Skip to content

Commit d8b0d53

Browse files
author
mkandil
committed
remove filter function from protocol and add it to the extenstion
1 parent b34dcbd commit d8b0d53

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

stdlib/public/Cxx/CxxDictionary.swift

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,23 @@ public protocol CxxDictionary<Key, Value> {
4141

4242
/// Do not implement this function manually in Swift.
4343
func __endUnsafe() -> RawIterator
44+
}
4445

45-
<<<<<<< HEAD
4646
/// Do not implement this function manually in Swift.
4747
mutating func __endMutatingUnsafe() -> RawMutableIterator
48-
=======
48+
49+
extension CxxDictionary {
50+
@inlinable
51+
public subscript(key: Key) -> Value? {
52+
get {
53+
let iter = __findUnsafe(key)
54+
guard iter != __endUnsafe() else {
55+
return nil
56+
}
57+
return iter.pointee.second
58+
}
59+
}
60+
4961
func filter(
5062
_ isIncluded: (Key, Value) throws -> Bool
5163
) rethrows -> [Key: Value] {
@@ -61,7 +73,6 @@ public protocol CxxDictionary<Key, Value> {
6173
iterator.successor()
6274
}
6375
}
64-
>>>>>>> 2dccec95be3 (Add filter method for ordered and unordered map)
6576
}
6677

6778
extension CxxDictionary {
@@ -90,4 +101,4 @@ extension CxxDictionary {
90101
}
91102
}
92103
}
93-
}
104+
}

0 commit comments

Comments
 (0)