Generic Type Alias

LazyMapCollection

A Collection whose elements consist of those in a Base Collection passed through a transform function returning Element. These elements are computed lazily, each time they’re read, by calling the transform function on a base element.

Declaration

typealias LazyMapCollection<T, U> = LazyMapSequence<T, U> where T : Collection

Topics

Instance Properties

var count: Int

The number of elements in the collection.

var endIndex: Base.Index

The collection’s “past the end” position—that is, the position one greater than the last valid subscript argument.

var indices: LazyMapSequence<Base, Element>.Indices

The indices that are valid for subscripting the collection, in ascending order.

var isEmpty: Bool

A Boolean value indicating whether the collection is empty.

var lazy: LazyCollection<LazyMapSequence<Base, Element>>

A sequence containing the same elements as this sequence, but on which some operations, such as map and filter, are implemented lazily.

var startIndex: Base.Index

The position of the first element in a nonempty collection.

Instance Methods

func distance(from: LazyMapSequence<Base, Element>.Index, to: LazyMapSequence<Base, Element>.Index) -> Int

Returns the distance between two indices.

func dropFirst(Int) -> LazyMapCollection<Base.SubSequence, Element>

Returns a subsequence containing all but the given number of initial elements.

func dropLast(Int) -> LazyMapCollection<Base.SubSequence, Element>

Returns a subsequence containing all but the specified number of final elements.

func firstIndex(where: (Element) -> Bool) -> Base.Index?

Returns the first index in which an element of the collection satisfies the given predicate.

func formIndex(after: inout LazyMapSequence<Base, Element>.Index)

Replaces the given index with its successor.

func formIndex(before: inout LazyMapSequence<Base, Element>.Index)

Replaces the given index with its predecessor.

func index(LazyMapSequence<Base, Element>.Index, offsetBy: Int) -> LazyMapSequence<Base, Element>.Index

Returns an index that is the specified distance from the given index.

func index(LazyMapSequence<Base, Element>.Index, offsetBy: Int, limitedBy: LazyMapSequence<Base, Element>.Index) -> LazyMapSequence<Base, Element>.Index?

Returns an index that is the specified distance from the given index, unless that distance is beyond a given limiting index.

func index(after: LazyMapSequence<Base, Element>.Index) -> LazyMapSequence<Base, Element>.Index

Returns the position immediately after the given index.

func index(before: LazyMapSequence<Base, Element>.Index) -> LazyMapSequence<Base, Element>.Index

A value less than or equal to the number of elements in the collection.

func map<T>((Element) -> T) -> [T]

Returns an array containing the results of mapping the given closure over the sequence’s elements.

func prefix(Int) -> LazyMapCollection<Base.SubSequence, Element>

Returns a subsequence, up to the specified maximum length, containing the initial elements of the collection.

func prefix(through: Base.Index) -> LazyMapCollection<Base.SubSequence, Element>

Returns a subsequence from the start of the collection through the specified position.

func prefix(upTo: Base.Index) -> LazyMapCollection<Base.SubSequence, Element>

Returns a subsequence from the start of the collection up to, but not including, the specified position.

func split(maxSplits: Int, omittingEmptySubsequences: Bool, whereSeparator: (Element) -> Bool) -> [LazyMapCollection<Base.SubSequence, Element>]

Returns the longest possible subsequences of the collection, in order, that don’t contain elements satisfying the given predicate.

func suffix(Int) -> LazyMapCollection<Base.SubSequence, Element>

Returns a subsequence, up to the given maximum length, containing the final elements of the collection.

func suffix(from: Base.Index) -> LazyMapCollection<Base.SubSequence, Element>

Returns a subsequence from the specified position to the end of the collection.

Subscripts

subscript<R>(R) -> LazyMapCollection<Base.SubSequence, Element>

Accesses the contiguous subrange of the collection’s elements specified by a range expression.

subscript(Range<Base.Index>) -> LazyMapSequence<Base, Element>.SubSequence

Accesses a contiguous subrange of the collection’s elements.

subscript(Base.Index) -> Element

Accesses the element at position.

See Also

Lazy Wrappers

struct LazySequence

A sequence containing the same elements as a Base sequence, but on which some operations such as map and filter are implemented lazily.

struct LazyMapSequence

A Sequence whose elements consist of those in a Base Sequence passed through a transform function returning Element. These elements are computed lazily, each time they’re read, by calling the transform function on a base element.

struct LazyFilterSequence

A sequence whose elements consist of the elements of some base sequence that also satisfy a given predicate.

struct LazyPrefixWhileSequence

A sequence whose elements consist of the initial consecutive elements of some base sequence that satisfy a given predicate.

struct LazyDropWhileSequence

A sequence whose elements consist of the elements that follow the initial consecutive elements of some base sequence that satisfy a given predicate.

typealias LazyCollection

A collection containing the same elements as a Base collection, but on which some operations such as map and filter are implemented lazily.

typealias LazyDropWhileCollection

A lazy wrapper that includes the elements of an underlying collection after any initial consecutive elements that satisfy a predicate.

typealias LazyFilterCollection

A lazy Collection wrapper that includes the elements of an underlying collection that satisfy a predicate.

typealias LazyPrefixWhileCollection

A lazy collection wrapper that includes the initial consecutive elements of an underlying collection that satisfy a predicate.