Improve storage

This commit is contained in:
Christoph Hagen
2024-12-19 16:25:05 +01:00
parent 9c828ff80a
commit 41887a1401
30 changed files with 926 additions and 831 deletions

View File

@ -8,4 +8,22 @@ extension Collection {
}
return sorted { conversion($0) < conversion($1) }
}
func count(where predicate: (Element) throws -> Bool) rethrows -> Int {
try reduce(0) { count, element in
try predicate(element) ? count + 1 : count
}
}
func countThrows(where predicate: (Element) throws -> Void) -> Int {
reduce(0) { count, element in
do {
try predicate(element)
return count
} catch {
return count + 1
}
}
}
}