Skip to content

Commit 195e031

Browse files
mdznrMatt Zanchelli
and
Matt Zanchelli
authored
Update comments in Chunked.swift (apple#179)
* Use back ticks around code references * Add missing spaces before parenthesis * Use “passed” instead of “past” Add missing comma Add back ticks around code references Add missing space before parenthesis * Consistently use spaces around `%` operator Co-authored-by: Matt Zanchelli <[email protected]>
1 parent da475ea commit 195e031

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

Sources/Algorithms/Chunked.swift

+13-13
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ extension Collection {
303303
/// A collection that presents the elements of its base collection in
304304
/// `SubSequence` chunks of any given count.
305305
///
306-
/// A `ChunksOfCountCollection` is a lazy view on the base Collection, but it
306+
/// A `ChunksOfCountCollection` is a lazy view on the base `Collection`, but it
307307
/// does not implicitly confer laziness on algorithms applied to its result. In
308308
/// other words, for ordinary collections `c`:
309309
///
@@ -486,11 +486,11 @@ extension ChunksOfCountCollection {
486486
_ i: Index, _ distance: Int
487487
) -> Int {
488488
if i == endIndex {
489-
let remainder = base.count%chunkCount
489+
let remainder = base.count % chunkCount
490490
// We have to take it into account when calculating offsets.
491491
if remainder != 0 {
492-
// Distance "minus" one(at this point distance is negative) because we
493-
// need to adjust for the last position that have a variadic(remainder)
492+
// Distance "minus" one (at this point distance is negative) because we
493+
// need to adjust for the last position that have a variadic (remainder)
494494
// number of elements.
495495
return ((distance + 1) * chunkCount) - remainder
496496
}
@@ -512,7 +512,7 @@ extension ChunksOfCountCollection {
512512
)
513513
}
514514

515-
// Helper to compute index(offsetBy:) index.
515+
// Helper to compute `index(offsetBy:)` index.
516516
@inlinable
517517
internal func makeOffsetIndex(
518518
from i: Index, baseBound: Base.Index, distance: Int, baseDistance: Int,
@@ -525,13 +525,13 @@ extension ChunksOfCountCollection {
525525

526526
if let limit = limit {
527527
if baseIdx == nil {
528-
// If we past the bounds while advancing forward and the limit is the
529-
// `endIndex`, since the computation on base don't take into account the
530-
// remainder, we have to make sure that passing the bound was because of
531-
// the distance not just because of a remainder. Special casing is less
532-
// expensive than always use count(which could be O(n) for non-random
533-
// access collection base) to compute the base distance taking remainder
534-
// into account.
528+
// If we passed the bounds while advancing forward, and the limit is the
529+
// `endIndex`, since the computation on `base` don't take into account
530+
// the remainder, we have to make sure that passing the bound was
531+
// because of the distance not just because of a remainder. Special
532+
// casing is less expensive than always using `count` (which could be
533+
// O(n) for non-random access collection base) to compute the base
534+
// distance taking remainder into account.
535535
if baseDistance > 0 && limit == endIndex {
536536
if self.distance(from: i, to: limit) < distance {
537537
return nil
@@ -561,7 +561,7 @@ extension Collection {
561561
/// Returns a `ChunksOfCountCollection<Self>` view presenting the elements in
562562
/// chunks with count of the given count parameter.
563563
///
564-
/// - Parameter count: The size of the chunks. If the count parameter is
564+
/// - Parameter count: The size of the chunks. If the `count` parameter is
565565
/// evenly divided by the count of the base `Collection` all the chunks will
566566
/// have the count equals to size. Otherwise, the last chunk will contain
567567
/// the remaining elements.

0 commit comments

Comments
 (0)