Skip to content

Commit 6388692

Browse files
committed
Add a few missing doc comments.
1 parent 99152ec commit 6388692

8 files changed

+32
-33
lines changed

Sources/Algorithms/Chain.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public struct Chain2<Base1: Sequence, Base2: Sequence>
2626
}
2727

2828
extension Chain2: Sequence {
29-
/// The iterator for a `Chain` sequence.
29+
/// The iterator for a `Chain2` sequence.
3030
public struct Iterator: IteratorProtocol {
3131
@usableFromInline
3232
internal var iterator1: Base1.Iterator
@@ -53,7 +53,7 @@ extension Chain2: Sequence {
5353
}
5454

5555
extension Chain2: Collection where Base1: Collection, Base2: Collection {
56-
/// A position in a `Chain` collection.
56+
/// A position in a `Chain2` collection.
5757
public struct Index: Comparable {
5858
// The internal index representation, which can either be an index of the
5959
// first collection or the second. The `endIndex` of the first collection

Sources/Algorithms/Chunked.swift

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
//
1010
//===----------------------------------------------------------------------===//
1111

12+
/// A collection wrapper that breaks a collection into chunks based on a
13+
/// predicate or projection.
1214
public struct LazyChunked<Base: Collection, Subject> {
1315
/// The collection that this instance provides a view onto.
1416
public let base: Base

Sources/Algorithms/Combinations.swift

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
//
1010
//===----------------------------------------------------------------------===//
1111

12+
/// A collection wrapper that generates combinations of a base collection.
1213
public struct Combinations<Base: Collection> {
1314
/// The collection to iterate over for combinations.
1415
public let base: Base
@@ -40,6 +41,7 @@ public struct Combinations<Base: Collection> {
4041
}
4142

4243
extension Combinations: Sequence {
44+
/// The iterator for a `Combinations` instance.
4345
public struct Iterator: IteratorProtocol {
4446
@usableFromInline
4547
internal let base: Base

Sources/Algorithms/Intersperse.swift

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ extension Intersperse: Sequence {
5555
}
5656

5757
extension Intersperse: Collection where Base: Collection {
58+
/// A position in an `Intersperse` collection.
5859
public struct Index: Comparable {
5960
enum Representation: Equatable {
6061
case element(Base.Index)

Sources/Algorithms/Permutations.swift

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public struct Permutations<Base: Collection> {
3232
}
3333

3434
extension Permutations: Sequence {
35+
/// The iterator for a `Permutations` instance.
3536
public struct Iterator: IteratorProtocol {
3637
@usableFromInline
3738
internal var base: Base

Sources/Algorithms/SlidingWindows.swift

+7-4
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@ extension Collection {
3030
}
3131
}
3232

33+
/// A collection wrapper that presents a sliding window over the elements of
34+
/// a collection.
3335
public struct SlidingWindows<Base: Collection> {
34-
3536
public let base: Base
3637
public let size: Int
3738

38-
private var firstUpperBound: Base.Index?
39+
internal var firstUpperBound: Base.Index?
3940

40-
init(base: Base, size: Int) {
41+
internal init(base: Base, size: Int) {
4142
precondition(size > 0, "SlidingWindows size must be greater than zero")
4243
self.base = base
4344
self.size = size
@@ -46,13 +47,15 @@ public struct SlidingWindows<Base: Collection> {
4647
}
4748

4849
extension SlidingWindows: Collection {
49-
50+
/// A position in a `SlidingWindows` collection.
5051
public struct Index: Comparable {
5152
internal var lowerBound: Base.Index
5253
internal var upperBound: Base.Index
54+
5355
public static func == (lhs: Index, rhs: Index) -> Bool {
5456
lhs.lowerBound == rhs.lowerBound
5557
}
58+
5659
public static func < (lhs: Index, rhs: Index) -> Bool {
5760
lhs.lowerBound < rhs.lowerBound
5861
}

Sources/Algorithms/Stride.swift

+15-25
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ extension Sequence {
3232
}
3333
}
3434

35+
/// A wrapper that strides over a base sequence or collection.
3536
public struct Stride<Base: Sequence> {
37+
internal let base: Base
38+
internal let stride: Int
3639

37-
let base: Base
38-
let stride: Int
39-
40-
init(base: Base, stride: Int) {
40+
internal init(base: Base, stride: Int) {
4141
precondition(stride > 0, "striding must be greater than zero")
4242
self.base = base
4343
self.stride = stride
@@ -51,12 +51,11 @@ extension Stride {
5151
}
5252

5353
extension Stride: Sequence {
54-
54+
/// An iterator over a `Stride` sequence.
5555
public struct Iterator: IteratorProtocol {
56-
57-
var iterator: Base.Iterator
58-
let stride: Int
59-
var striding: Bool = false
56+
internal var iterator: Base.Iterator
57+
internal let stride: Int
58+
internal var striding: Bool = false
6059

6160
public mutating func next() -> Base.Element? {
6261
guard striding else {
@@ -76,12 +75,11 @@ extension Stride: Sequence {
7675
}
7776

7877
extension Stride: Collection where Base: Collection {
79-
78+
/// A position in a `Stride` collection.
8079
public struct Index: Comparable {
80+
internal let base: Base.Index
8181

82-
let base: Base.Index
83-
84-
init(_ base: Base.Index) {
82+
internal init(_ base: Base.Index) {
8583
self.base = base
8684
}
8785

@@ -192,29 +190,21 @@ extension Stride: BidirectionalCollection
192190
}
193191
}
194192

195-
extension Stride: RandomAccessCollection
196-
where Base: RandomAccessCollection {}
193+
extension Stride: RandomAccessCollection where Base: RandomAccessCollection {}
197194

198-
extension Stride: Equatable
199-
where Base.Element: Equatable {
200-
195+
extension Stride: Equatable where Base.Element: Equatable {
201196
public static func == (lhs: Stride, rhs: Stride) -> Bool {
202197
lhs.elementsEqual(rhs, by: ==)
203198
}
204-
205199
}
206200

207-
extension Stride: Hashable
208-
where Base.Element: Hashable {
209-
201+
extension Stride: Hashable where Base.Element: Hashable {
210202
public func hash(into hasher: inout Hasher) {
211203
hasher.combine(stride)
212204
for element in self {
213205
hasher.combine(element)
214206
}
215207
}
216-
217208
}
218209

219-
extension Stride.Index: Hashable
220-
where Base.Index: Hashable {}
210+
extension Stride.Index: Hashable where Base.Index: Hashable {}

Sources/Algorithms/Trim.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
//===----------------------------------------------------------------------===//
1111

1212
extension BidirectionalCollection {
13-
1413
/// Returns a `SubSequence` formed by discarding all elements at the start and
1514
/// end of the collection which satisfy the given predicate.
1615
///
@@ -30,18 +29,19 @@ extension BidirectionalCollection {
3029
public func trimming(
3130
where predicate: (Element) throws -> Bool
3231
) rethrows -> SubSequence {
33-
3432
// Consume elements from the front.
3533
let sliceStart = try firstIndex { try predicate($0) == false } ?? endIndex
3634
// sliceEnd is the index _after_ the last index to match the predicate.
3735
var sliceEnd = endIndex
36+
3837
while sliceStart != sliceEnd {
3938
let idxBeforeSliceEnd = index(before: sliceEnd)
4039
guard try predicate(self[idxBeforeSliceEnd]) else {
4140
return self[sliceStart..<sliceEnd]
4241
}
4342
sliceEnd = idxBeforeSliceEnd
4443
}
44+
4545
// Trimmed everything.
4646
return self[Range(uncheckedBounds: (sliceStart, sliceStart))]
4747
}

0 commit comments

Comments
 (0)