Utils
import Utils
Module information
- Declarations
- 835
- Symbols
- 1341
import Utils
@discardableResult func all<T, E>(promises: [Promise<T, E>]) -> Promise<[T], E> where T : Sendable, E : Error
Returns a new promise that completes once all results from the individual promises have returned. This means that they possibly execute concurrently.
func allNonNil<T>(_ array: [T?]) -> [T]? where T : Equatable
func ascendingComparator<T, P>(comparing property: @escaping (T) -> P) -> (T, T) -> Bool where P : Comparable
A higher-order function that produces an ascending comparator (as used by sorted(by:)) comparing a specific property.
func ascendingComparator<T, P, R>(comparing property: @escaping (T) -> P, then inner: @escaping (T) -> R) -> (T, T) -> Bool where P : Comparable, R : Comparable
A higher-order function that produces an ascending comparator (as used by sorted(by:)) comparing a specific property.
func descendingComparator<T, P>(comparing property: @escaping (T) -> P) -> (T, T) -> Bool where P : Comparable
A higher-order function that produces a descending comparator (as used by sorted(by:)) comparing two specific properties lexicographically.
func descendingComparator<T, P, R>(comparing property: @escaping (T) -> P, then inner: @escaping (T) -> R) -> (T, T) -> Bool where P : Comparable, R : Comparable
A higher-order function that produces a descending comparator (as used by sorted(by:)) comparing two specific properties lexicographically.
func greatestCommonDivisor<I>(_ lhs: I, _ rhs: I) -> I where I : Equatable, I : ExpressibleByIntegerLiteral, I : Remainderable
func integerFactor<I>(_ n: I, _ c: I = 1) -> I? where I : ExpressibleByIntegerLiteral, I : Strideable, I : Addable, I : Divisible, I : Magnitudable, I : Multipliable, I : Remainderable, I : Subtractable, I == I.Magnitude, I.Stride : SignedInteger
Finds a nontrivial scale of the given number.
func isPrime<I>(_ n: I) -> Bool where I : ExpressibleByIntegerLiteral, I : Strideable, I : Divisible, I : Remainderable, I.Stride : SignedInteger
Deterministically checks whether a number is prime.
func leastCommonMultiple<I>(_ lhs: I, _ rhs: I) -> I where I : Equatable, I : ExpressibleByIntegerLiteral, I : Divisible, I : Multipliable, I : Remainderable
func parseClosedIntRange(from str: String) -> ClosedRange<Int>?
func parseHostPort(from raw: String) -> (String, Int32?)?
func parseIntRange(from str: String) -> Range<Int>?
func phantom<P>() -> Phantom<P>
func primeFactorization<I>(_ n: I) -> [I] where I : ExpressibleByIntegerLiteral, I : Strideable, I : Addable, I : Divisible, I : Magnitudable, I : Multipliable, I : Remainderable, I : Subtractable, I == I.Magnitude, I.Stride : SignedInteger
Finds the prime factorization of the given integer.
@discardableResult func sequence<T, C, E>(promises: C) -> Promise<[T], E> where T : Sendable, C : Collection, C : Sendable, E : Error, C.Element == () -> Promise<T, E>, C.SubSequence : Sendable
Sequentially executes the promises.
func %% (lhs: Int, rhs: Int) -> Int
Computes the floor/clock modulus. Useful for cyclic indexing.
func ** (lhs: Int, rhs: Int) -> Int
protocol Absolutable
protocol Addable
protocol AsyncBijection : Sendable
protocol AsyncRunnable
protocol Bijection : AsyncBijection
protocol ConstBool
protocol ConstInt
protocol DefaultInitializable
protocol Distribution
protocol Divisible
protocol KeyParameterizable
Anything with an enumerable key.
protocol LowBoundedIntRange : Sequence where Self.Element == Int
protocol Magnitudable
protocol Multipliable
protocol Negatable
Describes a (signed) type that has an additive inverse.
protocol PriorityQueue
A data structure that allows efficient insertion and dequeueing of prioritized items.
protocol Remainderable
protocol Runnable
protocol SearchTree
protocol Startable
protocol StringEnum : CaseIterable, Hashable
protocol Subtractable
protocol UnsignedConvertible
struct AnyAsyncBijection<V> where V : Sendable
struct AnyBijection<V>
struct AnyCodable
struct AnyCodingKey
actor AsyncLazyExpiring<T>
A value that periodically expires and gets re-queried through a supplied getter.
@propertyWrapper class AutoSerializing<T> where T : Decodable, T : Encodable
Wraps a value that is automatically read from/written to a file.
struct Averager
Collects useful statistics on the fly with constant memory consumption.
class AvlTree<Element> where Element : Comparable
A balanced binary search tree.
enum Axis
An axis in the 2D-plane.
struct BiDictionary<K, V> where K : Hashable, V : Hashable
A dictionary supporting bidirectional lookup.
struct BinaryHeap<E> where E : Comparable
@propertyWrapper struct Binding<Value>
A mutable, reference-like property wrapper that can read and write a value.
struct BitArray
@propertyWrapper class Box<T>
A simple property wrapper that stores a value on the heap.
struct CircularArray<T>
struct Complex
A complex number, i.e. an element of the algebraic closure of the real numbers.
struct ComposedAsyncBijection<B, C> where B : AsyncBijection, C : AsyncBijection, B.Value == C.Value
struct ComposedBijection<B, C> where B : Bijection, C : Bijection, B.Value == C.Value
struct CustomDiscreteDistribution<T>
A discrete probability distribution created from custom values.
enum Direction
An axis-aligned direction in the 2D-plane.
enum DiskFileError
struct DiskJsonSerializer
struct DocumentToMarkdownConverter
Converts HTML documents into Markdown.
struct EmptyKey
enum EncodeError
@propertyWrapper struct Expiring<T>
A value that periodically expires and gets re-queried through a supplied getter.
class ExpiringList<T>
A linked list of expiring elements.
struct False
struct FibonacciSequence<Value> where Value : Equatable, Value : ExpressibleByIntegerLiteral, Value : Addable
struct Fifty
struct Five
enum FixedArray<T>
A workaround that provides a stack-allocated, fixed size array up to length 10 and falls back to dynamically allocation for longer arrays.
struct Four
struct Fourty
struct HTTPRequest
struct Hundred
struct IdentityBijection<V>
struct InverseAsyncBijection<B> where B : AsyncBijection
struct InverseBijection<B> where B : Bijection
@propertyWrapper class Lazy<V>
struct LazyDictionary<K, V> where K : Hashable
struct LegacyRegex
A wrapper around NSRegularExpression
with a more modern API.
struct Mat2<T> where T : ExpressibleByIntegerLiteral, T : Hashable, T : Absolutable, T : Addable, T : Divisible, T : Multipliable, T : Negatable, T : Subtractable
A linear transformation in 2D euclidean space.
struct Matrix<T> where T : ExpressibleByIntegerLiteral, T : Hashable, T : Absolutable, T : Addable, T : Divisible, T : Multipliable, T : Negatable, T : Subtractable
struct MutexLock
A basic synchronization primitive.
struct NDArray<T> where T : ExpressibleByIntegerLiteral, T : Hashable, T : Absolutable, T : Addable, T : Divisible, T : Multipliable, T : Negatable, T : Subtractable
A multidimensional, rectangular, numeric array. Generalization of a matrix/vector/scalar and sometimes referred to as ‘tensor’.
enum NDArrayError
struct NDArrayParser
enum NDArrayParserError
enum NetworkError
struct One
struct PeekableIterator<I> where I : IteratorProtocol
struct PhantomWrapped<T, P>
A wrapper that pretends as if it owns another type P
. Mainly useful for using generically specialized functions without actually accepting or returning a value of the type parameter.
final class Promise<T, E> where T : Sendable, E : Error
Represents an asynchronously computed value.
struct Rational
A numeric type supporting precise division.
class RepeatingTimer
struct Scaling<T> where T : Sendable, T : Divisible, T : Multipliable
struct Shell
A wrapper that simplifies the creation of subprocesses.
struct StableElement<E> where E : Comparable
struct StablePriorityQueue<Q, E> where Q : PriorityQueue, E : Comparable, Q.Element == StableElement<E>
A wrapper around a priority queue that ensures a FIFO order for elements of the same priority.
final class StringBuilder
Provides a fluent interface for building strings.
@propertyWrapper struct Synchronized<T>
A value with synchronized get/set.
class TemporaryDirectory
A custom temporary directory. The directory is deleted when this instance is deinitialized.
class TemporaryFile
A custom temporary file. The file is deleted when this instance is deinitialized if deleteAutomatically
is set.
struct Ten
struct Thirty
struct Three
struct Time
Represents a time, independent of the date. Often viewed as an hour-minute-second tuple.
struct TimerContext
class TokenIterator<T>
An iterator wrapper for a sequence of tokens that explicitly uses reference semantics.
struct Translation<T> where T : Sendable, T : Addable, T : Subtractable
struct True
struct Twenty
struct Two
@propertyWrapper struct UncheckedSendable<Value>
@dynamicMemberLookup struct UnionStringEnum<R, S> where R : StringEnum, S : StringEnum
struct Vec2<T>
struct Vector<T> where T : ExpressibleByIntegerLiteral, T : Hashable, T : Absolutable, T : Addable, T : Divisible, T : Multipliable, T : Negatable, T : Subtractable
struct Zero
typealias IntExpressibleAlgebraicField = Addable & Subtractable & Multipliable & Divisible & Negatable & ExpressibleByIntegerLiteral & Hashable & Absolutable
typealias Phantom<P> = PhantomWrapped<Void, P>
typealias StableBinaryHeap<E> = StablePriorityQueue<BinaryHeap<StableElement<E>>, E> where E : Comparable
struct NodePackage
A wrapper around an executable node package that is located in Node
under the current working directory.