Skip to main content Link Search Menu Expand Document (external link)

SortedMap overview

Added in v2.0.0


Table of contents


constructors

empty

Signature

export declare const empty: <K, V = never>(ord: Order<K>) => SortedMap<K, V>

Added in v2.0.0

fromIterable

Creates a new SortedMap from an iterable collection of key/value pairs.

Signature

export declare const fromIterable: {
  <B>(ord: Order<B>): <K extends B, V>(iterable: Iterable<readonly [K, V]>) => SortedMap<K, V>
  <K extends B, V, B>(iterable: Iterable<readonly [K, V]>, ord: Order<B>): SortedMap<K, V>
}

Added in v2.0.0

make

Signature

export declare const make: <K>(
  ord: Order<K>
) => <Entries extends ReadonlyArray<readonly [K, any]>>(
  ...entries: Entries
) => SortedMap<K, Entries[number] extends readonly [any, infer V] ? V : never>

Added in v2.0.0

elements

get

Signature

export declare const get: {
  <K>(key: K): <V>(self: SortedMap<K, V>) => Option.Option<V>
  <K, V>(self: SortedMap<K, V>, key: K): Option.Option<V>
}

Added in v2.0.0

has

Signature

export declare const has: {
  <K>(key: K): <V>(self: SortedMap<K, V>) => boolean
  <K, V>(self: SortedMap<K, V>, key: K): boolean
}

Added in v2.0.0

headOption

Signature

export declare const headOption: <K, V>(self: SortedMap<K, V>) => Option.Option<[K, V]>

Added in v2.0.0

lastOption

Signature

export declare const lastOption: <K, V>(self: SortedMap<K, V>) => Option.Option<[K, V]>

Added in v3.1.0

remove

Signature

export declare const remove: {
  <K>(key: K): <V>(self: SortedMap<K, V>) => SortedMap<K, V>
  <K, V>(self: SortedMap<K, V>, key: K): SortedMap<K, V>
}

Added in v2.0.0

set

Signature

export declare const set: {
  <K, V>(key: K, value: V): (self: SortedMap<K, V>) => SortedMap<K, V>
  <K, V>(self: SortedMap<K, V>, key: K, value: V): SortedMap<K, V>
}

Added in v2.0.0

filtering

partition

Signature

export declare const partition: {
  <K, V>(
    predicate: (a: Types.NoInfer<K>) => boolean
  ): (self: SortedMap<K, V>) => [excluded: SortedMap<K, V>, satisfying: SortedMap<K, V>]
  <K, V>(self: SortedMap<K, V>, predicate: (a: K) => boolean): [excluded: SortedMap<K, V>, satisfying: SortedMap<K, V>]
}

Added in v3.1.0

folding

reduce

Signature

export declare const reduce: {
  <B, A, K>(zero: B, f: (acc: B, value: A, key: K) => B): (self: SortedMap<K, A>) => B
  <K, A, B>(self: SortedMap<K, A>, zero: B, f: (acc: B, value: A, key: K) => B): B
}

Added in v2.0.0

getters

entries

Signature

export declare const entries: <K, V>(self: SortedMap<K, V>) => IterableIterator<[K, V]>

Added in v2.0.0

getOrder

Gets the Order<K> that the SortedMap<K, V> is using.

Signature

export declare const getOrder: <K, V>(self: SortedMap<K, V>) => Order<K>

Added in v2.0.0

keys

Signature

export declare const keys: <K, V>(self: SortedMap<K, V>) => IterableIterator<K>

Added in v2.0.0

size

Signature

export declare const size: <K, V>(self: SortedMap<K, V>) => number

Added in v2.0.0

values

Signature

export declare const values: <K, V>(self: SortedMap<K, V>) => IterableIterator<V>

Added in v2.0.0

mapping

map

Signature

export declare const map: {
  <A, K, B>(f: (a: A, k: K) => B): (self: SortedMap<K, A>) => SortedMap<K, B>
  <K, A, B>(self: SortedMap<K, A>, f: (a: A, k: K) => B): SortedMap<K, B>
}

Added in v2.0.0

models

SortedMap (interface)

Signature

export interface SortedMap<in out K, out V> extends Iterable<[K, V]>, Equal.Equal, Pipeable, Inspectable {
  readonly [TypeId]: {
    readonly _K: Types.Invariant<K>
    readonly _V: Types.Covariant<V>
  }
  /** @internal */
  readonly tree: RBT.RedBlackTree<K, V>
}

Added in v2.0.0

predicates

isEmpty

Signature

export declare const isEmpty: <K, V>(self: SortedMap<K, V>) => boolean

Added in v2.0.0

isNonEmpty

Signature

export declare const isNonEmpty: <K, V>(self: SortedMap<K, V>) => boolean

Added in v2.0.0

refinements

isSortedMap

Signature

export declare const isSortedMap: {
  <K, V>(u: Iterable<readonly [K, V]>): u is SortedMap<K, V>
  (u: unknown): u is SortedMap<unknown, unknown>
}

Added in v2.0.0

symbol

TypeId (type alias)

Signature

export type TypeId = typeof TypeId

Added in v2.0.0