1919public protocol CxxSet < Element> : ExpressibleByArrayLiteral {
2020 associatedtype Element
2121 associatedtype Size : BinaryInteger
22+ associatedtype RawIterator : UnsafeCxxInputIterator
23+ where RawIterator. Pointee == Element
24+ associatedtype RawMutableIterator : UnsafeCxxInputIterator
25+ where RawMutableIterator. Pointee == Element
2226
2327 // std::pair<iterator, bool> for std::set and std::unordered_set
2428 // iterator for std::multiset
25- associatedtype InsertionResult
29+ associatedtype InsertionResult
2630
2731 init ( )
2832
33+ func __endUnsafe( ) -> RawIterator
34+ func __findUnsafe( _ value: Element ) -> RawIterator
35+
2936 @discardableResult
3037 mutating func __insertUnsafe( _ element: Element ) -> InsertionResult
31-
3238 func count( _ element: Element ) -> Size
3339}
3440
@@ -56,7 +62,7 @@ extension CxxSet {
5662 /// in the set.
5763 @inlinable
5864 public func contains( _ element: Element ) -> Bool {
59- return count ( element) > 0
65+ return self . __findUnsafe ( element) != self . __endUnsafe ( )
6066 }
6167}
6268
@@ -65,23 +71,11 @@ extension CxxSet {
6571/// C++ standard library types such as `std::set` and `std::unordered_set`
6672/// conform to this protocol.
6773public protocol CxxUniqueSet < Element> : CxxSet {
68- override associatedtype Element
69- override associatedtype Size : BinaryInteger
70- associatedtype RawIterator : UnsafeCxxInputIterator
71- where RawIterator. Pointee == Element
72- associatedtype RawMutableIterator : UnsafeCxxInputIterator
73- where RawMutableIterator. Pointee == Element
7474 override associatedtype InsertionResult
7575 where InsertionResult: CxxPair < RawMutableIterator , Bool >
7676
77- @discardableResult
78- mutating func __findUnsafe( _ value: Element ) -> RawIterator
79-
8077 @discardableResult
8178 mutating func __eraseUnsafe( _ iter: RawIterator ) -> RawMutableIterator
82-
83- @discardableResult
84- mutating func __endUnsafe( ) -> RawIterator
8579}
8680
8781extension CxxUniqueSet {
0 commit comments