Skip to content

Commit 74c223f

Browse files
authored
Merge pull request #67309 from apple/egorzhdan/5.9-doc-overlay-protocols
🍒[cxx-interop] NFC: Add doc comments for overlay protocols
2 parents 756b03a + 5bdb5ac commit 74c223f

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

stdlib/public/Cxx/CxxDictionary.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
/// A C++ type that represents a dictionary.
14+
///
15+
/// C++ standard library types such as `std::map` and `std::unordered_map`
16+
/// conform to this protocol.
1317
public protocol CxxDictionary<Key, Value> {
1418
associatedtype Key
1519
associatedtype Value

stdlib/public/Cxx/CxxPair.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
/// A C++ type that represents a pair of two values.
14+
///
15+
/// C++ standard library type `std::pair` conforms to this protocol.
1316
public protocol CxxPair<First, Second> {
1417
associatedtype First
1518
associatedtype Second

stdlib/public/Cxx/CxxSet.swift

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
/// A C++ type that represents a set of values, which might be repeating.
14+
///
15+
/// C++ standard library types such as `std::set`, `std::unordered_set` and
16+
/// `std::multiset` conform to this protocol.
17+
///
18+
/// - SeeAlso: `CxxUniqueSet`
1319
public protocol CxxSet<Element> {
1420
associatedtype Element
1521
associatedtype Size: BinaryInteger
@@ -41,12 +47,18 @@ extension CxxSet {
4147
}
4248
}
4349

50+
/// Returns a Boolean value that indicates whether the given element exists
51+
/// in the set.
4452
@inlinable
4553
public func contains(_ element: Element) -> Bool {
4654
return count(element) > 0
4755
}
4856
}
4957

58+
/// A C++ type that represents a set of unique values.
59+
///
60+
/// C++ standard library types such as `std::set` and `std::unordered_set`
61+
/// conform to this protocol.
5062
public protocol CxxUniqueSet<Element>: CxxSet {
5163
override associatedtype Element
5264
override associatedtype Size: BinaryInteger
@@ -57,12 +69,22 @@ public protocol CxxUniqueSet<Element>: CxxSet {
5769
}
5870

5971
extension CxxUniqueSet {
72+
/// Inserts the given element in the set if it is not already present.
73+
///
74+
/// If an element equal to `newMember` is already contained in the set, this
75+
/// method has no effect.
76+
///
77+
/// - Parameter newMember: An element to insert into the set.
78+
/// - Returns: `(true, newMember)` if `newMember` was not contained in the
79+
/// set. If an element equal to `newMember` was already contained in the
80+
/// set, the method returns `(false, oldMember)`, where `oldMember` is the
81+
/// element that was equal to `newMember`.
6082
@inlinable
6183
@discardableResult
6284
public mutating func insert(
63-
_ element: Element
85+
_ newMember: Element
6486
) -> (inserted: Bool, memberAfterInsert: Element) {
65-
let insertionResult = self.__insertUnsafe(element)
87+
let insertionResult = self.__insertUnsafe(newMember)
6688
let rawIterator: RawMutableIterator = insertionResult.first
6789
let inserted: Bool = insertionResult.second
6890
return (inserted, rawIterator.pointee)

0 commit comments

Comments
 (0)