Skip to content

Commit 29366d0

Browse files
committed
Slight changes to index(_:offsetBy:) discussion.
1 parent a0917b8 commit 29366d0

File tree

6 files changed

+13
-12
lines changed

6 files changed

+13
-12
lines changed

stdlib/public/core/Array.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ extension Array: RandomAccessCollection, MutableCollection {
438438
/// - Returns: An index offset by `distance` from the index `i`. If
439439
/// `distance` is positive, this is the same value as the result of
440440
/// `distance` calls to `index(after:)`. If `distance` is negative, this
441-
/// is the same value as the result of `-distance` calls to
441+
/// is the same value as the result of `abs(distance)` calls to
442442
/// `index(before:)`.
443443
@inlinable
444444
public func index(_ i: Int, offsetBy distance: Int) -> Int {

stdlib/public/core/ArraySlice.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ extension ArraySlice: RandomAccessCollection, MutableCollection {
261261
/// - Returns: An index offset by `distance` from the index `i`. If
262262
/// `distance` is positive, this is the same value as the result of
263263
/// `distance` calls to `index(after:)`. If `distance` is negative, this
264-
/// is the same value as the result of `-distance` calls to
264+
/// is the same value as the result of `abs(distance)` calls to
265265
/// `index(before:)`.
266266
@inlinable
267267
public func index(_ i: Int, offsetBy distance: Int) -> Int {

stdlib/public/core/Collection.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ public protocol Collection: Sequence where SubSequence: Collection {
669669
/// - Returns: An index offset by `distance` from the index `i`. If
670670
/// `distance` is positive, this is the same value as the result of
671671
/// `distance` calls to `index(after:)`. If `distance` is negative, this
672-
/// is the same value as the result of `-distance` calls to
672+
/// is the same value as the result of `abs(distance)` calls to
673673
/// `index(before:)`.
674674
///
675675
/// - Complexity: O(1) if the collection conforms to
@@ -874,7 +874,7 @@ extension Collection {
874874
/// - Returns: An index offset by `distance` from the index `i`. If
875875
/// `distance` is positive, this is the same value as the result of
876876
/// `distance` calls to `index(after:)`. If `distance` is negative, this
877-
/// is the same value as the result of `-distance` calls to
877+
/// is the same value as the result of `abs(distance)` calls to
878878
/// `index(before:)`.
879879
///
880880
/// - Complexity: O(1) if the collection conforms to

stdlib/public/core/ContiguousArray.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ extension ContiguousArray: RandomAccessCollection, MutableCollection {
170170
/// - Returns: An index offset by `distance` from the index `i`. If
171171
/// `distance` is positive, this is the same value as the result of
172172
/// `distance` calls to `index(after:)`. If `distance` is negative, this
173-
/// is the same value as the result of `-distance` calls to
173+
/// is the same value as the result of `abs(distance)` calls to
174174
/// `index(before:)`.
175175
@inlinable
176176
public func index(_ i: Int, offsetBy distance: Int) -> Int {

stdlib/public/core/RandomAccessCollection.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ where Index : Strideable,
223223
/// - Returns: An index offset by `distance` from the index `i`. If
224224
/// `distance` is positive, this is the same value as the result of
225225
/// `distance` calls to `index(after:)`. If `distance` is negative, this
226-
/// is the same value as the result of `-distance` calls to
226+
/// is the same value as the result of `abs(distance)` calls to
227227
/// `index(before:)`.
228228
///
229229
/// - Complexity: O(1)

stdlib/public/core/StringRangeReplaceableCollection.swift

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,17 @@ extension String : StringProtocol, RangeReplaceableCollection {
150150
/// print(s[i])
151151
/// // Prints "t"
152152
///
153-
/// The value passed as `distance` must not offset `i` beyond the bounds of the
154-
/// collection.
153+
/// The value passed as `distance` must not offset `i` beyond the bounds of
154+
/// the collection.
155155
///
156156
/// - Parameters:
157157
/// - i: A valid index of the collection.
158158
/// - distance: The distance to offset `i`.
159-
/// - Returns: An index offset by `distance` from the index `i`. If `distance` is positive,
160-
/// this is the same value as the result of `distance` calls to `index(after:)`.
161-
/// If `distance` is negative, this is the same value as the result of `-distance` calls
162-
/// to `index(before:)`.
159+
/// - Returns: An index offset by `distance` from the index `i`. If
160+
/// `distance` is positive, this is the same value as the result of
161+
/// `distance` calls to `index(after:)`. If `distance` is negative, this
162+
/// is the same value as the result of `abs(distance)` calls to
163+
/// `index(before:)`.
163164
///
164165
/// - Complexity: O(*k*), where *k* is the absolute value of `distance`.
165166
public func index(_ i: Index, offsetBy distance: IndexDistance) -> Index {

0 commit comments

Comments
 (0)