LazyFilterIndex

struct LazyFilterIndex<BaseElements : CollectionType>

The Index used for subscripting a LazyFilterCollection.

The positions of a LazyFilterIndex correspond to those positions p in its underlying collection c such that c[p] satisfies the predicate with which the LazyFilterIndex was initialized.

Note: The performance of advancing a LazyFilterIndex depends on how sparsely the filtering predicate is satisfied, and may not offer the usual performance given by models of ForwardIndexType.

Inheritance Equatable, ForwardIndexType, _Incrementable View Protocol Hierarchy →
Import import Swift

Instance Variables

var base: BaseElements.Index

The position corresponding to self in the underlying collection.

Declaration

var base: BaseElements.Index { get }

Instance Methods

func advancedBy(_:)

Returns the result of advancing self by n positions.

Returns: - If n > 0, the result of applying successor to self n times. - If n < 0, the result of applying predecessor to self -n times. - Otherwise, self.

Requires: n >= 0 if only conforming to ForwardIndexType Complexity: - O(1) if conforming to RandomAccessIndexType - O(abs(n)) otherwise

Declaration

func advancedBy(n: LazyFilterIndex<BaseElements>.Distance) -> LazyFilterIndex<BaseElements>

Declared In

ForwardIndexType
func advancedBy(_:limit:)

Returns the result of advancing self by n positions, or until it equals limit.

Returns: - If n > 0, the result of applying successor to self n times but not past limit. - If n < 0, the result of applying predecessor to self -n times but not past limit. - Otherwise, self.

Requires: n >= 0 if only conforming to ForwardIndexType.

Complexity: - O(1) if conforming to RandomAccessIndexType - O(abs(n)) otherwise

Declaration

func advancedBy(n: LazyFilterIndex<BaseElements>.Distance, limit: LazyFilterIndex<BaseElements>) -> LazyFilterIndex<BaseElements>

Declared In

ForwardIndexType
func distanceTo(_:)

Measure the distance between self and end.

Requires: - start and end are part of the same sequence when conforming to RandomAccessSequenceType. - end is reachable from self by incrementation otherwise.

Complexity: - O(1) if conforming to RandomAccessIndexType - O(n) otherwise, where n is the function's result.

Declaration

func distanceTo(end: LazyFilterIndex<BaseElements>) -> LazyFilterIndex<BaseElements>.Distance

Declared In

ForwardIndexType
func successor()

Returns the next consecutive value after self.

Requires: The next value is representable.

Complexity: Amortized O(M), where M is the average distance in the base collection between elements that satisfy the predicate.

Note: This operation may not satisfy the expected complexity for models of ForwardIndexType.

Declaration

func successor() -> LazyFilterIndex<BaseElements>