AsyncFilterSequence
An asynchronous sequence that contains, in order, the elements of the base sequence that satisfy a given predicate.
- iOS
- 13.0+
- macOS
- 10.15+
- tvOS
- 13.0+
- watchOS
- 6.0+
struct AsyncFilterSequence<Base> where Base : AsyncSequence
An asynchronous sequence that contains, in order, the elements of the base sequence that satisfy a given predicate.
struct AsyncFilterSequence<Base> where Base : AsyncSequence
import _Concurrency
protocol AsyncSequence<Element, Failure>
A type that provides asynchronous, sequential, iterated access to its elements.
protocol Copyable
A type whose values can be implicitly or explicitly copied.
protocol Escapable
func makeAsyncIterator() -> AsyncFilterSequence<Base>.Iterator
struct Iterator
The iterator that produces elements of the filter sequence.
typealias AsyncIterator = AsyncFilterSequence<Base>.Iterator
The type of iterator that produces elements of the sequence.
typealias Element = Base.Element
The type of element produced by this asynchronous sequence.
typealias Failure = Base.Failure
The type of the error that can be produced by the sequence.
func allSatisfy(_ predicate: (Self.Element) async throws -> Bool) async rethrows -> Bool
Returns a Boolean value that indicates whether all elements produced by the asynchronous sequence satisfy the given predicate.
@preconcurrency func compactMap<ElementOfResult>(_ transform: @escaping (Self.Element) async -> ElementOfResult?) -> AsyncCompactMapSequence<Self, ElementOfResult>
Creates an asynchronous sequence that maps the given closure over the asynchronous sequence’s elements, omitting results that don’t return a value.
@preconcurrency func compactMap<ElementOfResult>(_ transform: @escaping (Self.Element) async throws -> ElementOfResult?) -> AsyncThrowingCompactMapSequence<Self, ElementOfResult>
Creates an asynchronous sequence that maps an error-throwing closure over the base sequence’s elements, omitting results that don’t return a value.
func contains(_ search: Self.Element) async rethrows -> Bool
Returns a Boolean value that indicates whether the asynchronous sequence contains the given element.
func contains(where predicate: (Self.Element) async throws -> Bool) async rethrows -> Bool
Returns a Boolean value that indicates whether the asynchronous sequence contains an element that satisfies the given predicate.
@preconcurrency func drop(while predicate: @escaping (Self.Element) async -> Bool) -> AsyncDropWhileSequence<Self>
Omits elements from the base asynchronous sequence until a given closure returns false, after which it passes through all remaining elements.
func dropFirst(_ count: Int = 1) -> AsyncDropFirstSequence<Self>
Omits a specified number of elements from the base asynchronous sequence, then passes through all remaining elements.
@preconcurrency func filter(_ isIncluded: @escaping (Self.Element) async -> Bool) -> AsyncFilterSequence<Self>
Creates an asynchronous sequence that contains, in order, the elements of the base sequence that satisfy the given predicate.
func first(where predicate: (Self.Element) async throws -> Bool) async rethrows -> Self.Element?
Returns the first element of the sequence that satisfies the given predicate.
@preconcurrency func flatMap<SegmentOfResult>(_ transform: @escaping (Self.Element) async throws -> SegmentOfResult) -> AsyncThrowingFlatMapSequence<Self, SegmentOfResult> where SegmentOfResult : AsyncSequence
Creates an asynchronous sequence that concatenates the results of calling the given error-throwing transformation with each element of this sequence.
@preconcurrency func flatMap<SegmentOfResult>(_ transform: @escaping (Self.Element) async -> SegmentOfResult) -> AsyncFlatMapSequence<Self, SegmentOfResult> where SegmentOfResult : AsyncSequence, Self.Failure == SegmentOfResult.Failure
Creates an asynchronous sequence that concatenates the results of calling the given transformation with each element of this sequence.
@preconcurrency func flatMap<SegmentOfResult>(_ transform: @escaping (Self.Element) async -> SegmentOfResult) -> AsyncFlatMapSequence<Self, SegmentOfResult> where SegmentOfResult : AsyncSequence, SegmentOfResult.Failure == Never
Creates an asynchronous sequence that concatenates the results of calling the given transformation with each element of this sequence.
@preconcurrency func flatMap<SegmentOfResult>(_ transform: @escaping (Self.Element) async -> SegmentOfResult) -> AsyncFlatMapSequence<Self, SegmentOfResult> where SegmentOfResult : AsyncSequence, Self.Failure == Never, SegmentOfResult.Failure == Never
Creates an asynchronous sequence that concatenates the results of calling the given transformation with each element of this sequence.
@preconcurrency func map<Transformed>(_ transform: @escaping (Self.Element) async -> Transformed) -> AsyncMapSequence<Self, Transformed>
Creates an asynchronous sequence that maps the given closure over the asynchronous sequence’s elements.
@preconcurrency func map<Transformed>(_ transform: @escaping (Self.Element) async throws -> Transformed) -> AsyncThrowingMapSequence<Self, Transformed>
Creates an asynchronous sequence that maps the given error-throwing closure over the asynchronous sequence’s elements.
@warn_unqualified_access func max() async rethrows -> Self.Element?
Returns the maximum element in an asynchronous sequence of comparable elements.
@warn_unqualified_access func max(by areInIncreasingOrder: (Self.Element, Self.Element) async throws -> Bool) async rethrows -> Self.Element?
Returns the maximum element in the asynchronous sequence, using the given predicate as the comparison between elements.
@warn_unqualified_access func min() async rethrows -> Self.Element?
Returns the minimum element in an asynchronous sequence of comparable elements.
@warn_unqualified_access func min(by areInIncreasingOrder: (Self.Element, Self.Element) async throws -> Bool) async rethrows -> Self.Element?
Returns the minimum element in the asynchronous sequence, using the given predicate as the comparison between elements.
func prefix(_ count: Int) -> AsyncPrefixSequence<Self>
Returns an asynchronous sequence, up to the specified maximum length, containing the initial elements of the base asynchronous sequence.
@preconcurrency func prefix(while predicate: @escaping (Self.Element) async -> Bool) rethrows -> AsyncPrefixWhileSequence<Self>
Returns an asynchronous sequence, containing the initial, consecutive elements of the base sequence that satisfy the given predicate.
func reduce<Result>(_ initialResult: Result, _ nextPartialResult: (Result, Self.Element) async throws -> Result) async rethrows -> Result
Returns the result of combining the elements of the asynchronous sequence using the given closure.
func reduce<Result>(into initialResult: Result, _ updateAccumulatingResult: (inout Result, Self.Element) async throws -> Void) async rethrows -> Result
Returns the result of combining the elements of the asynchronous sequence using the given closure, given a mutable initial value.
protocol Sendable