Projections

A Sequence whose elements are projections, through a lens of type BaseElementPart, of the elements of some Base sequence.

Projections is analogous to LazyMapSequence but doesn’t store a closure or a KeyPath, and when Base conforms to MutableCollection, so does Projections<Base, L>, as long as L.Focus is-a WritableKeyPath.

  • The type of each element of self.

  • Single-pass iteration interface and state for instances of Self.

    See more
  • Returns an iterator over the elements of this sequence.

  • A value <= self.count.

  • A position in an instance of Self.

  • The indices of the elements in an instance of self.

  • The position of the first element, or endIndex if self.isEmpty.

  • The position immediately after the last element.

  • The indices of all elements, in order.

  • The position following x.

  • Replaces x with its successor

  • Accesses the element at i.

  • True iff self contains no elements.

  • The number of elements in self.

    Complexity

    O(1) if Base conforms to RandomAccessCollection; otherwise, O(N) where N is the number of elements.
  • Returns an index that is the specified distance from the given index.

    Complexity

    O(1) if Base conforms to RandomAccessCollection; otherwise, O(distance).
  • Returns i offset forward by distance, unless that distance is beyond a given limiting index, in which case nil is returned.

    Complexity

    O(1) if Base conforms to RandomAccessCollection; otherwise, O(distance).
  • Returns the number of positions between start to end.

    Complexity

    O(1) if Base conforms to RandomAccessCollection; otherwise, worst case O(count).
  • Returns the position immediately before i.

  • Replaces the value of i with its predecessor.