AnyCursor
A type-erased cursor.
final class AnyCursor<Element>
An instance of AnyCursor
forwards its operations to an underlying base cursor having the same Element
type, hiding the specifics of the underlying cursor.
A type-erased cursor.
final class AnyCursor<Element>
An instance of AnyCursor
forwards its operations to an underlying base cursor having the same Element
type, hiding the specifics of the underlying cursor.
import GRDB
A toolkit for SQLite databases, with a focus on application development
final class DropFirstCursor<Base> where Base : Cursor
A Cursor
that consumes and drops n elements from an underlying Base
cursor before possibly returning the first available element.
final class DropWhileCursor<Base> where Base : Cursor
A Cursor
whose elements consist of the elements that follow the initial consecutive elements of some Base
cursor that satisfy a given predicate.
final class EnumeratedCursor<Base> where Base : Cursor
An enumeration of the elements of a cursor.
final class FilterCursor<Base> where Base : Cursor
A Cursor
whose elements consist of the elements of some Base
cursor that also satisfy a given predicate.
final class FlattenCursor<Base> where Base : Cursor, Base.Element : Cursor
A Cursor
consisting of all the elements contained in each segment contained in some Base
cursor.
final class MapCursor<Base, Element> where Base : Cursor
A Cursor
whose elements consist of those in a Base
cursor passed through a transform function returning Element.
final class PrefixCursor<Base> where Base : Cursor
A Cursor
that only consumes up to n
elements from an underlying Base
cursor.
final class PrefixWhileCursor<Base> where Base : Cursor
A Cursor
whose elements consist of the initial consecutive elements of some Base
cursor that satisfy a given predicate.
protocol Cursor<Element> : AnyObject
A type that supplies the values of some external resource, one at a time.
init<C>(_ base: C) where Element == C.Element, C : Cursor
Creates a new cursor that wraps and forwards operations to base
.
convenience init(_ sequence: some Sequence<Element>)
Creates a new cursor whose elements are elements of sequence
.
init(_ next: @escaping () throws -> Element?)
Creates a cursor that wraps the given closure in its next
method.
convenience init(iterator: some IteratorProtocol<Element>)
Creates a new cursor whose elements are elements of iterator
.
func next() throws -> Element?
var isEmpty: Bool { get throws }
Returns a Boolean value indicating whether the cursor does not contain any element.
func compactMap<ElementOfResult>(_ transform: @escaping (Element) throws -> ElementOfResult?) -> MapCursor<FilterCursor<MapCursor<Self, ElementOfResult?>>, ElementOfResult>
Returns a cursor over the concatenated non-nil results of mapping transform over this cursor.
func contains(_ element: Element) throws -> Bool
Returns a Boolean value indicating whether the cursor contains the given element.
func contains(where predicate: (Element) throws -> Bool) throws -> Bool
Returns a Boolean value indicating whether the cursor contains an element that satisfies the given predicate.
func drop(while predicate: @escaping (Element) throws -> Bool) -> DropWhileCursor<Self>
Returns a cursor that skips any initial elements that satisfy predicate
.
func dropFirst() -> DropFirstCursor<Self>
Returns a cursor containing all but the first element of the cursor.
func dropFirst(_ n: Int) -> DropFirstCursor<Self>
Returns a cursor containing all but the given number of initial elements.
func dropLast() throws -> [Element]
Returns an array containing all but the last element of the cursor.
func dropLast(_ n: Int) throws -> [Element]
Returns an array containing all but the given number of final elements.
func enumerated() -> EnumeratedCursor<Self>
Returns a cursor of pairs (n, x), where n represents a consecutive integer starting at zero, and x represents an element of the cursor.
func filter(_ isIncluded: @escaping (Element) throws -> Bool) -> FilterCursor<Self>
Returns the elements of the cursor that satisfy the given predicate.
func first(where predicate: (Element) throws -> Bool) throws -> Element?
Returns the first element of the cursor that satisfies the given predicate or nil if no such element is found.
func flatMap<SegmentOfResult>(_ transform: @escaping (Element) throws -> SegmentOfResult) -> FlattenCursor<MapCursor<Self, AnyCursor<SegmentOfResult.Element>>> where SegmentOfResult : Sequence
Returns a cursor over the concatenated results of mapping transform over self.
func flatMap<SegmentOfResult>(_ transform: @escaping (Element) throws -> SegmentOfResult) -> FlattenCursor<MapCursor<Self, SegmentOfResult>> where SegmentOfResult : Cursor
Returns a cursor over the concatenated results of mapping transform over self.
func forEach(_ body: (Element) throws -> Void) throws
Calls the given closure on each element in the cursor.
func joined() -> FlattenCursor<Self>
Returns the elements of this cursor of cursors, concatenated.
func joined() -> FlattenCursor<MapCursor<Self, AnyCursor<Element.Element>>>
Returns the elements of this cursor of sequences, concatenated.
func joined(separator: String = "") throws -> String
Returns the elements of this cursor of sequences, concatenated.
func map<T>(_ transform: @escaping (Element) throws -> T) -> MapCursor<Self, T>
Returns a cursor over the results of the transform function applied to this cursor’s elements.
func max() throws -> Element?
Returns the maximum element in the cursor.
func max(by areInIncreasingOrder: (Element, Element) throws -> Bool) throws -> Element?
Returns the maximum element in the cursor, using the given predicate as the comparison between elements.
func min() throws -> Element?
Returns the minimum element in the cursor.
func min(by areInIncreasingOrder: (Element, Element) throws -> Bool) throws -> Element?
Returns the minimum element in the cursor, using the given predicate as the comparison between elements.
func prefix(_ maxLength: Int) -> PrefixCursor<Self>
Returns a cursor, up to the specified maximum length, containing the initial elements of the cursor.
func prefix(while predicate: @escaping (Element) throws -> Bool) -> PrefixWhileCursor<Self>
Returns a cursor of the initial consecutive elements that satisfy predicate
.
func reduce<Result>(_ initialResult: Result, _ nextPartialResult: (Result, Element) throws -> Result) throws -> Result
Returns the result of calling the given combining closure with each element of this cursor and an accumulating value.
func reduce<Result>(into initialResult: Result, _ updateAccumulatingResult: (inout Result, Element) throws -> Void) throws -> Result
Returns the result of calling the given combining closure with each element of this cursor and an accumulating value.
func suffix(_ maxLength: Int) throws -> [Element]
Returns an array, up to the given maximum length, containing the final elements of the cursor.