Chunks
public struct Chunks<Base> where Base : Collection
extension Chunks: Collection
A collection contiguous slices partitioning a some base collection.
-
The collection being partitioned.
Declaration
Swift
private let base: Base -
The maximum number of elements in a single chunk.
Declaration
Swift
private let chunkCapacity: Int -
Creates an instance that partitions
baseinto batches at mostmaxCountslices.If
maxCountis greater than or equal tobase.count,selfwill containbase.countcollections of one element frombase. Otherwise,selfwill containmaxCountelements of at mostbase.count / maxCount + 1element.Requires
maxCount > 0Declaration
Swift
public init(partitioning base: Base, inMax maxCount: Int) -
Returns
base.Declaration
Swift
public func joined() -> Base -
A position in
Chunks.Declaration
Swift
public typealias Index = Base.Index -
An element in
Chunks.Declaration
Swift
public typealias Element = Base.SubSequence -
The first position in
self.Declaration
Swift
public var startIndex: Index { get } -
The “past the end” position in
self.Declaration
Swift
public var endIndex: Index { get } -
The position after
iinself. -
Accesses the chunk at
position.
View on GitHub