Sequence

public extension Sequence
public extension Sequence where Element: Equatable
public extension Sequence where Element: BinaryFloatingPoint
public extension Sequence where Element: Occupiable
public extension Sequence where Element: OptionalType
  • Returns self as Array.

    Declaration

    Swift

    var asArray: [Element] { get }

Splitting

  • Undocumented

    Declaration

    Swift

    func splitBefore(separator isSeparator: (Iterator.Element) -> Bool) -> [AnySequence<Iterator.Element>]

Scripting

  • Undocumented

    Declaration

    Swift

    @inlinable
    func count(where isIncluded: (Element) throws -> Bool) rethrows -> Int
  • Helper method to filter out duplicates. Element will be filtered out if closure return true.

    Declaration

    Swift

    @inlinable
    func filterDuplicates(_ includeElement: (_ lhs: Element, _ rhs: Element) throws -> Bool) rethrows -> [Element]
  • Transforms an array to a dictionary using array elements as keys and transform result as values.

    Declaration

    Swift

    @inlinable
    func dictionaryMap<T>(_ transform: (_ element: Iterator.Element) throws -> T?) rethrows -> [Iterator.Element : T] where Self.Element : Hashable

Available where Element: Equatable

  • Returns whether collection has at least one common element with passed array.

    Declaration

    Swift

    @inlinable
    func hasIntersection(with array: [Element]) -> Bool
  • Returns intersection array.

    Declaration

    Swift

    @inlinable
    func intersection(with array: [Element]) -> [Element]
  • Helper method to filter out duplicates

    Declaration

    Swift

    @inlinable
    func filterDuplicates() -> [Element]

Available where Element: BinaryFloatingPoint

  • Returns averge value of all elements in a sequence.

    Declaration

    Swift

    func average() -> Element

Available where Element: Occupiable

  • Returns an array containing, in order, the elements of the sequence filtering out all empty elements.

    Declaration

    Swift

    func filterEmpty() -> [Element]

    Return Value

    An array of non-empty elements with preserved order.

Available where Element: OptionalType

  • Undocumented

    Declaration

    Swift

    func filterNil() -> [Element.Wrapped]