@@ -25,6 +25,8 @@ public protocol CxxDictionary<Key, Value> {
25
25
associatedtype Size : BinaryInteger
26
26
associatedtype InsertionResult
27
27
28
+ init ( )
29
+
28
30
/// Do not implement this function manually in Swift.
29
31
func __findUnsafe( _ key: Key ) -> RawIterator
30
32
@@ -61,24 +63,6 @@ extension CxxDictionary {
61
63
return iter. pointee. second
62
64
}
63
65
}
64
-
65
- func filter(
66
- _ isIncluded: ( _ key: Key , _ value: Value ) throws -> Bool
67
- ) rethrows -> [ Key : Value ] {
68
- var filteredDictionary : [ Key : Value ] = [ : ]
69
- var iterator = __beginUnsafe ( Key)
70
- let endIterator = __endUnsafe ( )
71
-
72
- while iterator != endIterator {
73
- let pair = iterator. pointee
74
- if try isIncluded ( pair. first, pair. second) {
75
- filteredDictionary [ pair. first] = pair. second
76
- }
77
- iterator = iterator. successor ( )
78
- }
79
-
80
- return filteredDictionary
81
- }
82
66
}
83
67
84
68
extension CxxDictionary {
@@ -107,4 +91,22 @@ extension CxxDictionary {
107
91
}
108
92
}
109
93
}
94
+
95
+ public func filter(
96
+ _ isIncluded: ( _ key: Key , _ value: Value ) throws -> Bool
97
+ ) rethrows -> Self {
98
+ var filteredDictionary : Self . init ( )
99
+ var iterator = __beginUnsafe ( )
100
+ let endIterator = __endUnsafe ( )
101
+
102
+ while iterator != endIterator {
103
+ let pair = iterator. pointee
104
+ if try isIncluded ( pair. first, pair. second) {
105
+ filteredDictionary [ pair. first] = pair. second
106
+ }
107
+ iterator = iterator. successor ( )
108
+ }
109
+
110
+ return filteredDictionary
111
+ }
110
112
}
0 commit comments