Skip to content

Commit dca2544

Browse files
author
Tim Vermeulen
authored
Rename the LazyChunked type to Chunked (#121)
* Rename LazyChunked -> Chunked * Add deprecated typealias for `LazyChunked`
1 parent 1639c1e commit dca2544

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

Guides/Chunked.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ extension Collection {
7676
extension LazyCollectionProtocol {
7777
public func chunked(
7878
by belongInSameGroup: @escaping (Element, Element) -> Bool
79-
) -> LazyChunked<Elements>
79+
) -> Chunked<Elements>
8080

8181
public func chunked<Subject: Equatable>(
8282
on projection: @escaping (Element) -> Subject
83-
) -> LazyChunked<Elements>
83+
) -> Chunked<Elements>
8484
}
8585
```
8686

87-
The `LazyChunked` type is bidirectional when the wrapped collection is
87+
The `Chunked` type is bidirectional when the wrapped collection is
8888
bidirectional.
8989

9090
### Complexity

Sources/Algorithms/Chunked.swift

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
/// A collection wrapper that breaks a collection into chunks based on a
1313
/// predicate or projection.
14-
public struct LazyChunked<Base: Collection, Subject> {
14+
public struct Chunked<Base: Collection, Subject> {
1515
/// The collection that this instance provides a view onto.
1616
@usableFromInline
1717
internal let base: Base
@@ -45,7 +45,7 @@ public struct LazyChunked<Base: Collection, Subject> {
4545
}
4646
}
4747

48-
extension LazyChunked: LazyCollectionProtocol {
48+
extension Chunked: LazyCollectionProtocol {
4949
/// A position in a chunked collection.
5050
public struct Index: Comparable {
5151
/// The range corresponding to the chunk at this position.
@@ -106,9 +106,9 @@ extension LazyChunked: LazyCollectionProtocol {
106106
}
107107
}
108108

109-
extension LazyChunked.Index: Hashable where Base.Index: Hashable {}
109+
extension Chunked.Index: Hashable where Base.Index: Hashable {}
110110

111-
extension LazyChunked: BidirectionalCollection
111+
extension Chunked: BidirectionalCollection
112112
where Base: BidirectionalCollection
113113
{
114114
/// Returns the index in the base collection of the start of the chunk ending
@@ -131,6 +131,9 @@ extension LazyChunked: BidirectionalCollection
131131
}
132132
}
133133

134+
@available(*, deprecated, renamed: "Chunked")
135+
public typealias LazyChunked<Base: Collection, Subject> = Chunked<Base, Subject>
136+
134137
//===----------------------------------------------------------------------===//
135138
// lazy.chunked(by:)
136139
//===----------------------------------------------------------------------===//
@@ -143,8 +146,8 @@ extension LazyCollectionProtocol {
143146
@inlinable
144147
public func chunked(
145148
by belongInSameGroup: @escaping (Element, Element) -> Bool
146-
) -> LazyChunked<Elements, Element> {
147-
LazyChunked(
149+
) -> Chunked<Elements, Element> {
150+
Chunked(
148151
base: elements,
149152
projection: { $0 },
150153
belongInSameGroup: belongInSameGroup)
@@ -157,8 +160,8 @@ extension LazyCollectionProtocol {
157160
@inlinable
158161
public func chunked<Subject: Equatable>(
159162
on projection: @escaping (Element) -> Subject
160-
) -> LazyChunked<Elements, Subject> {
161-
LazyChunked(
163+
) -> Chunked<Elements, Subject> {
164+
Chunked(
162165
base: elements,
163166
projection: projection,
164167
belongInSameGroup: ==)

0 commit comments

Comments
 (0)