RedBlackTree
Constants
Constructors
Creates an empty RedBlackTree.
Signature
declare const empty: <K, V = never>(ord: Order<K>) => RedBlackTree<K, V>fromIterable
Creates a new RedBlackTree from an iterable collection of key/value pairs.
Signature
declare const fromIterable: { <B>(ord: Order<B>): <K, V>(entries: Iterable<readonly [K, V]>) => RedBlackTree<K, V>; <K, V, B>(entries: Iterable<readonly [K, V]>, ord: Order<B>): RedBlackTree<K, V>;}Constructs a new RedBlackTree from the specified entries.
Signature
declare const make: <K>(ord: Order<K>) => <Entries extends Array<readonly [K, any]>>(...entries: Entries) => RedBlackTree<K, Entries[number] extends readonly [any, infer V] ? V : never>Elements
Finds all values in the tree associated with the specified key.
Signature
declare const findAll: { <K>(key: K): <V>(self: RedBlackTree<K, V>) => Chunk<V>; <K, V>(self: RedBlackTree<K, V>, key: K): Chunk<V>;}Finds the first value in the tree associated with the specified key, if it exists.
Signature
declare const findFirst: { <K>(key: K): <V>(self: RedBlackTree<K, V>) => Option<V>; <K, V>(self: RedBlackTree<K, V>, key: K): Option<V>;}Returns the element at the specified index within the tree or None if the
specified index does not exist.
Signature
declare const getAt: { (index: number): <K, V>(self: RedBlackTree<K, V>) => Option<[K, V]>; <K, V>(self: RedBlackTree<K, V>, index: number): Option<[K, V]>;}Finds the item with key, if it exists.
Signature
declare const has: { <K>(key: K): <V>(self: RedBlackTree<K, V>) => boolean; <K, V>(self: RedBlackTree<K, V>, key: K): boolean;}Folding
Getters
Returns the first entry in the tree, if it exists.
Signature
declare const first: <K, V>(self: RedBlackTree<K, V>) => Option<[K, V]>Gets the Order<K> that the RedBlackTree<K, V> is using.
Signature
declare const getOrder: <K, V>(self: RedBlackTree<K, V>) => Order<K>Get all the keys present in the tree in order.
Signature
declare const keys: <K, V>(self: RedBlackTree<K, V>) => IterableIterator<K>keysReversed
Get all the keys present in the tree in reverse order.
Signature
declare const keysReversed: <K, V>(self: RedBlackTree<K, V>) => IterableIterator<K>Returns the last entry in the tree, if it exists.
Signature
declare const last: <K, V>(self: RedBlackTree<K, V>) => Option<[K, V]>Returns the size of the tree.
Signature
declare const size: <K, V>(self: RedBlackTree<K, V>) => numberGet all values present in the tree in order.
Signature
declare const values: <K, V>(self: RedBlackTree<K, V>) => IterableIterator<V>valuesReversed
Get all values present in the tree in reverse order.
Signature
declare const valuesReversed: <K, V>(self: RedBlackTree<K, V>) => IterableIterator<V>Models
RedBlackTree interface
A Red-Black Tree.
Signature
interface RedBlackTree<in out Key, out Value> extends Iterable<[Key, Value]>, Equal, Pipeable, Inspectable { readonly [TypeId]: { readonly _Key: Invariant<Key>; readonly _Value: Covariant<Value>; };}Other
Insert a new item into the tree.
Signature
declare const insert: { <K, V>(key: K, value: V): (self: RedBlackTree<K, V>) => RedBlackTree<K, V>; <K, V>(self: RedBlackTree<K, V>, key: K, value: V): RedBlackTree<K, V>;}RedBlackTree
removeFirst
Removes the entry with the specified key, if it exists.
Signature
declare const removeFirst: { <K>(key: K): <V>(self: RedBlackTree<K, V>) => RedBlackTree<K, V>; <K, V>(self: RedBlackTree<K, V>, key: K): RedBlackTree<K, V>;}Refinements
isRedBlackTree
Signature
declare const isRedBlackTree: { <K, V>(u: Iterable<readonly [K, V]>): u is RedBlackTree<K, V>; (u: unknown): u is RedBlackTree<unknown, unknown>;}Symbol
Traversing
Returns an iterator that points to the element at the specified index of the tree.
Note: The iterator will run through elements in order.
Signature
declare const at: { (index: number): <K, V>(self: RedBlackTree<K, V>) => Iterable<[K, V]>; <K, V>(self: RedBlackTree<K, V>, index: number): Iterable<[K, V]>;}atReversed
Returns an iterator that points to the element at the specified index of the tree.
Note: The iterator will run through elements in reverse order.
Signature
declare const atReversed: { (index: number): <K, V>(self: RedBlackTree<K, V>) => Iterable<[K, V]>; <K, V>(self: RedBlackTree<K, V>, index: number): Iterable<[K, V]>;}Execute the specified function for each node of the tree, in order.
Signature
declare const forEach: { <K, V>(f: (key: K, value: V) => void): (self: RedBlackTree<K, V>) => void; <K, V>(self: RedBlackTree<K, V>, f: (key: K, value: V) => void): void;}forEachBetween
Visit each node of the tree in order with key lower than max and greater than or equal to min.
Signature
declare const forEachBetween: { <K, V>(options: { readonly body: (key: K, value: V) => void; readonly max: K; readonly min: K; }): (self: RedBlackTree<K, V>) => void; <K, V>(self: RedBlackTree<K, V>, options: { readonly body: (key: K, value: V) => void; readonly max: K; readonly min: K; }): void;}forEachGreaterThanEqual
Visit each node of the tree in order with key greater then or equal to max.
Signature
declare const forEachGreaterThanEqual: { <K, V>(min: K, f: (key: K, value: V) => void): (self: RedBlackTree<K, V>) => void; <K, V>(self: RedBlackTree<K, V>, min: K, f: (key: K, value: V) => void): void;}forEachLessThan
Visit each node of the tree in order with key lower then max.
Signature
declare const forEachLessThan: { <K, V>(max: K, f: (key: K, value: V) => void): (self: RedBlackTree<K, V>) => void; <K, V>(self: RedBlackTree<K, V>, max: K, f: (key: K, value: V) => void): void;}greaterThan
Returns an iterator that traverse entries in order with keys greater than the specified key.
Signature
declare const greaterThan: { <K>(key: K): <V>(self: RedBlackTree<K, V>) => Iterable<[K, V]>; <K, V>(self: RedBlackTree<K, V>, key: K): Iterable<[K, V]>;}greaterThanEqual
Returns an iterator that traverse entries in order with keys greater than or equal to the specified key.
Signature
declare const greaterThanEqual: { <K>(key: K): <V>(self: RedBlackTree<K, V>) => Iterable<[K, V]>; <K, V>(self: RedBlackTree<K, V>, key: K): Iterable<[K, V]>;}greaterThanEqualReversed
Returns an iterator that traverse entries in reverse order with keys greater than or equal to the specified key.
Signature
declare const greaterThanEqualReversed: { <K>(key: K): <V>(self: RedBlackTree<K, V>) => Iterable<[K, V]>; <K, V>(self: RedBlackTree<K, V>, key: K): Iterable<[K, V]>;}greaterThanReversed
Returns an iterator that traverse entries in reverse order with keys greater than the specified key.
Signature
declare const greaterThanReversed: { <K>(key: K): <V>(self: RedBlackTree<K, V>) => Iterable<[K, V]>; <K, V>(self: RedBlackTree<K, V>, key: K): Iterable<[K, V]>;}Returns an iterator that traverse entries in order with keys less than the specified key.
Signature
declare const lessThan: { <K>(key: K): <V>(self: RedBlackTree<K, V>) => Iterable<[K, V]>; <K, V>(self: RedBlackTree<K, V>, key: K): Iterable<[K, V]>;}lessThanEqual
Returns an iterator that traverse entries in order with keys less than or equal to the specified key.
Signature
declare const lessThanEqual: { <K>(key: K): <V>(self: RedBlackTree<K, V>) => Iterable<[K, V]>; <K, V>(self: RedBlackTree<K, V>, key: K): Iterable<[K, V]>;}lessThanEqualReversed
Returns an iterator that traverse entries in reverse order with keys less than or equal to the specified key.
Signature
declare const lessThanEqualReversed: { <K>(key: K): <V>(self: RedBlackTree<K, V>) => Iterable<[K, V]>; <K, V>(self: RedBlackTree<K, V>, key: K): Iterable<[K, V]>;}lessThanReversed
Returns an iterator that traverse entries in reverse order with keys less than the specified key.
Signature
declare const lessThanReversed: { <K>(key: K): <V>(self: RedBlackTree<K, V>) => Iterable<[K, V]>; <K, V>(self: RedBlackTree<K, V>, key: K): Iterable<[K, V]>;}Traverse the tree in reverse order.
Signature
declare const reversed: <K, V>(self: RedBlackTree<K, V>) => Iterable<[K, V]>