Skip to content

Commit 0c64fe4

Browse files
authored
Merge pull request #62869 from apple/egorzhdan/cxx-sequence-docs
[cxx-interop] NFC: Improve documentation comments
2 parents 75fcd23 + 2ac5ccf commit 0c64fe4

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

stdlib/public/Cxx/CxxConvertibleToCollection.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,14 @@ internal func forEachElement<C: CxxConvertibleToCollection>(
3838
}
3939

4040
extension Array {
41-
/// Creates an array containing the elements of a C++ collection.
41+
/// Creates an array containing the elements of a C++ container.
4242
///
43-
/// This initializer copies each element of the C++ collection to a new Swift
44-
/// array.
43+
/// This initializes the array by copying every element of the C++ container.
4544
///
4645
/// - Complexity: O(*n*), where *n* is the number of elements in the C++
47-
/// collection.
46+
/// container when each element is copied in O(1). Note that this might not
47+
/// be true for certain C++ types, e.g. those with a custom copy
48+
/// constructor that performs additional logic.
4849
public init<C: CxxConvertibleToCollection>(_ c: C)
4950
where C.RawIterator.Pointee == Element {
5051

@@ -54,13 +55,14 @@ extension Array {
5455
}
5556

5657
extension Set {
57-
/// Creates an set containing the elements of a C++ collection.
58+
/// Creates an set containing the elements of a C++ container.
5859
///
59-
/// This initializer copies each element of the C++ collection to a new Swift
60-
/// set.
60+
/// This initializes the set by copying every element of the C++ container.
6161
///
6262
/// - Complexity: O(*n*), where *n* is the number of elements in the C++
63-
/// collection.
63+
/// container when each element is copied in O(1). Note that this might not
64+
/// be true for certain C++ types, e.g. those with a custom copy
65+
/// constructor that performs additional logic.
6466
public init<C: CxxConvertibleToCollection>(_ c: C)
6567
where C.RawIterator.Pointee == Element {
6668

stdlib/public/Cxx/CxxSequence.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ public struct CxxIterator<T>: IteratorProtocol where T: CxxSequence {
123123
}
124124

125125
extension CxxSequence {
126+
/// Returns an iterator over the elements of this C++ container.
127+
///
128+
/// - Complexity: O(*n*), where *n* is the number of elements in the C++
129+
/// container when each element is copied in O(1). Note that this might not
130+
/// be true for certain C++ types, e.g. those with a custom copy
131+
/// constructor that performs additional logic.
126132
@inlinable
127133
public func makeIterator() -> CxxIterator<Self> {
128134
return CxxIterator(sequence: self)

0 commit comments

Comments
 (0)