Sequence

protocol Sequence
  • Mechanica Returns: the first element (if any) matching the predicate. - Parameters: - predicate: A closure that takes an element of the sequence as its argument and returns a Boolean value indicating whether the element is a match. - Note: Same as first(where:). - SeeAlso: first(where:)

    Declaration

    Swift

    public final func findFirst(where predicate: (Iterator.Element) -> Bool) -> Iterator.Element?

    Parameters

    predicate

    A closure that takes an element of the sequence as its argument and returns a Boolean value indicating whether the element is a match.

  • Mechanica

    Returns true if there is at least one element matching the predicate. - Parameters: - predicate: A closure that takes an element of the sequence as its argument and returns a Boolean value indicating whether the element is a match.

    Declaration

    Swift

    public final func hasSome(where predicate: (Iterator.Element) -> Bool) -> Bool

    Parameters

    predicate

    A closure that takes an element of the sequence as its argument and returns a Boolean value indicating whether the element is a match.

  • Mechanica

    Returns true if all the elements match the predicate. - Parameters: - predicate: A closure that takes an element of the sequence as its argument and returns a Boolean value indicating whether the element is a match.

    Declaration

    Swift

    public final func hasAll(where predicate: (Iterator.Element) -> Bool) -> Bool

    Parameters

    predicate

    A closure that takes an element of the sequence as its argument and returns a Boolean value indicating whether the element is a match.

  • Mechanica

    Declaration

    Swift

    public final func grouped<Key: Hashable>(by criteria: (Iterator.Element) -> (Key)) -> [Key : [Iterator.Element]]

    Parameters

    criteria

    The criteria closure takes an Iterator.Element and returns its classification.

    Return Value

    Returns a grouped dictionary with the keys that the criteria function returns.

  • Mechanica

    Returns the elements count matching a predicate. - Parameter shouldCount: A closure that takes an element of the sequence as its argument and returns a Boolean value indicating whether the element should be counted or not.

    Declaration

    Swift

    public final func count(_ shouldCount: (Iterator.Element) -> Bool) -> Int

    Parameters

    shouldCount

    A closure that takes an element of the sequence as its argument and returns a Boolean value indicating whether the element should be counted or not.

  • Mechanica

    Returns true if the Sequence contains an element identical (referential equality) to an object.

    Declaration

    Swift

    public final func containsObjectIdentical(to object: AnyObject) -> Bool