Slicing and Splitting
Iterate over tuple pairs of adjacent elements, overlapping windows of a specified size, or lazily-calculated splits.
Adjacent Pairs
func adjacentPairs(
) -> AdjacentPairsSequence<Self> Returns a sequence of overlapping adjacent pairs of the elements of this sequence.
func adjacentPairs(
) -> AdjacentPairsCollection<Self> Returns a collection of overlapping adjacent pairs of the elements of this collection.
Windows
func windows(ofCount: Int
) -> WindowsOfCountCollection<Self> Returns a collection of all the overlapping slices of a given size.
Lazily Splitting a Collection
func split(separator: Element, maxSplits: Int, omittingEmptySubsequences: Bool
) -> SplitSequence<Elements> Lazily returns the longest possible subsequences of the sequence, in order, around elements equal to the given element.
func split(maxSplits: Int, omittingEmptySubsequences: Bool, whereSeparator: @escaping (Element) -> Bool
) -> SplitSequence<Elements> Lazily returns the longest possible subsequences of the sequence, in order, that don’t contain elements satisfying the given predicate.
func split(separator: Element, maxSplits: Int, omittingEmptySubsequences: Bool
) -> SplitCollection<Elements> Lazily returns the longest possible subsequences of the collection, in order, around elements equal to the given element.
func split(maxSplits: Int, omittingEmptySubsequences: Bool, whereSeparator: @escaping (Element) -> Bool
) -> SplitCollection<Elements> Lazily returns the longest possible subsequences of the collection, in order, that don’t contain elements satisfying the given predicate.
Supporting Types
struct AdjacentPairsSequence<Base>
A sequence of adjacent pairs of elements built from an underlying sequence.
struct AdjacentPairsCollection<Base>
A collection of adjacent pairs of elements built from an underlying collection.
struct WindowsOfCountCollection<Base>
A collection wrapper that presents a sliding window over the elements of a collection.
struct SplitSequence<Base>
A sequence that lazily splits a base sequence into subsequences separated by elements that satisfy the given
whereSeparator
predicate.struct SplitCollection<Base>
A collection that lazily splits a base collection into subsequences separated by elements that satisfy the given
whereSeparator
predicate.