Rename the LazyChunked type to Chunked (#121)

* Rename LazyChunked -> Chunked
* Add deprecated typealias for `LazyChunked`
This commit is contained in:
Tim Vermeulen authored and GitHub committed 2021-04-07 09:43:37 -05:00
1 parent 1639c1e2c3
commit dca25448e0
2 files changed
+14 -11

No files matched your search

+3 -3
View File
@@ -76,15 +76,15 @@ extension Collection {
extension LazyCollectionProtocol {
public func chunked(
by belongInSameGroup: @escaping (Element, Element) -> Bool
) -> LazyChunked<Elements>
) -> Chunked<Elements>
public func chunked<Subject: Equatable>(
on projection: @escaping (Element) -> Subject
) -> LazyChunked<Elements>
) -> Chunked<Elements>
}
```
The `LazyChunked` type is bidirectional when the wrapped collection is
The `Chunked` type is bidirectional when the wrapped collection is
bidirectional.
### Complexity
+11 -8
View File
@@ -11,7 +11,7 @@
/// A collection wrapper that breaks a collection into chunks based on a
/// predicate or projection.
public struct LazyChunked<Base: Collection, Subject> {
public struct Chunked<Base: Collection, Subject> {
/// The collection that this instance provides a view onto.
@usableFromInline
internal let base: Base
@@ -45,7 +45,7 @@ public struct LazyChunked<Base: Collection, Subject> {
}
}
extension LazyChunked: LazyCollectionProtocol {
extension Chunked: LazyCollectionProtocol {
/// A position in a chunked collection.
public struct Index: Comparable {
/// The range corresponding to the chunk at this position.
@@ -106,9 +106,9 @@ extension LazyChunked: LazyCollectionProtocol {
}
}
extension LazyChunked.Index: Hashable where Base.Index: Hashable {}
extension Chunked.Index: Hashable where Base.Index: Hashable {}
extension LazyChunked: BidirectionalCollection
extension Chunked: BidirectionalCollection
where Base: BidirectionalCollection
{
/// Returns the index in the base collection of the start of the chunk ending
@@ -131,6 +131,9 @@ extension LazyChunked: BidirectionalCollection
}
}
@available(*, deprecated, renamed: "Chunked")
public typealias LazyChunked<Base: Collection, Subject> = Chunked<Base, Subject>
//===----------------------------------------------------------------------===//
// lazy.chunked(by:)
//===----------------------------------------------------------------------===//
@@ -143,8 +146,8 @@ extension LazyCollectionProtocol {
@inlinable
public func chunked(
by belongInSameGroup: @escaping (Element, Element) -> Bool
) -> LazyChunked<Elements, Element> {
LazyChunked(
) -> Chunked<Elements, Element> {
Chunked(
base: elements,
projection: { $0 },
belongInSameGroup: belongInSameGroup)
@@ -157,8 +160,8 @@ extension LazyCollectionProtocol {
@inlinable
public func chunked<Subject: Equatable>(
on projection: @escaping (Element) -> Subject
) -> LazyChunked<Elements, Subject> {
LazyChunked(
) -> Chunked<Elements, Subject> {
Chunked(
base: elements,
projection: projection,
belongInSameGroup: ==)