EnumeratedCursor
An enumeration of the elements of a cursor.
final class EnumeratedCursor<Base> where Base : Cursor
EnumeratedCursor
is a cursor of pairs (n, x), where ns are consecutive Int
values starting at zero, and xs are the elements of a Base
cursor.
To create an instance of EnumeratedCursor
, call enumerated()
on a cursor. For example:
let base = try String.fetchCursor(db, sql: """
SELECT 'foo' UNION ALL SELECT 'bar'
""")
let cursor = base.enumerated()
while let (n, x) = cursor.next() {
print("\(n): \(x)")
}
// Prints: "0: foo"
// Prints: "1: bar"