Skip to main content
Module

x/froebel/sortedMap.ts>default

A strictly typed utility library.
Go to Latest
class default
implements Map<K, V>
import { default } from "https://deno.land/x/froebel@v0.21.0/sortedMap.ts";

Behaves like a regular JavaScript Map, but its iteration order is dependant on the compare function supplied in the constructor.

Note: The item's sort position is only computed automatically on insertion. If you update one of the values that the compare function depends on, you must call the update(key) method afterwards to ensure the map stays sorted.

Constructors

new
default(compare: Cmp<K, V>, entries?: readonly (readonly [K, V])[] | null)

Properties

clear
entries: () => unknown
get
has
keys: () => unknown
readonly
size
values: () => unknown
[Symbol.iterator]: () => unknown
[Symbol.toStringTag]

Methods

delete(key: K)
forEach(callback: (
value: V,
key: K,
map: SortedMap<K, V>,
) => void
)
map<T>(callback: (
value: V,
key: K,
map: SortedMap<K, V>,
) => T
): T[]
set(key: K, value: V): this
update(key: K)

Update the sort position of the element at key if necessary.

This method should be called to notify the SortedMap that one of the parameters that the compare function depends on has been updated and consequently the sort order must be verified/updated.