Tanguv0.35.0
Collections14 exports
Raw Markdown

/sorted-map

B-Tree backed ordered map (Sorted-Map) maintaining keys in ascending sorted order.

(use /sorted-map)

Functions & symbols#

Sorted-Map#

constructor
(Sorted-Map [initial-entries]) -> Sorted-Map

Constructs a mutable `Sorted-Map` instance.

ParameterTypeOptionalDescription
initialMap | ArrayoptionalOptional initial Map or [k v] pairs
Returns:Any
(let m (Sorted-Map {:b 2 :a 1}))

contains-key?#

function
(contains-key? map key) -> Bool

Returns `true` if `key` exists in the map.

ParameterTypeOptionalDescription
mapSorted-MaprequiredMap
keyAnyrequiredKey to test
Returns:Any
(m/contains-key? m :b)

count#

function
(count map) -> Int

Alias of `count-of`: returns the entry count.

ParameterTypeOptionalDescription
mapSorted-MaprequiredSorted-Map instance
Returns:Any
(m/count m)

count-of#

function
(count-of map) -> Int

Returns the number of entries currently stored.

ParameterTypeOptionalDescription
mapSorted-MaprequiredSorted-Map instance
Returns:Any
(count-of m)

entries-of#

function
(entries-of map) -> (Array Array)

Returns all `[key value]` pairs as an Array.

ParameterTypeOptionalDescription
mapSorted-MaprequiredSorted-Map instance
Returns:Any
(entries-of m)

first-entry#

function
(first-entry map) -> (Or Array None)

Returns the `[key value]` pair with the smallest key, or `()`.

ParameterTypeOptionalDescription
mapSorted-MaprequiredSorted-Map instance
Returns:Any
(sorted-map/first-entry m)

get#

function
(get map key [default]) -> Any

Looks up `key` in `Sorted-Map`, returning `default` or `()` if missing.

ParameterTypeOptionalDescription
mapSorted-MaprequiredMap
keyAnyrequiredKey to look up
defaultAnyoptionalOptional fallback when key absent
Returns:Any
(m/get m :a)

into-iter#

function
(into-iter map) -> Iter

Returns an iterator yielding `[key value]` pairs.

ParameterTypeOptionalDescription
mapSorted-MaprequiredSorted-Map instance
Returns:Any
(into-iter m)

is-empty?#

function
(is-empty? map) -> Bool

Returns `true` when the map has zero entries.

ParameterTypeOptionalDescription
mapSorted-MaprequiredSorted-Map instance
Returns:Any
(is-empty? m)

keys-of#

function
(keys-of map) -> Array

Returns all keys as an Array (sorted for `Sorted-Map`).

ParameterTypeOptionalDescription
mapSorted-MaprequiredSorted-Map instance
Returns:Any
(keys-of m)

last-entry#

function
(last-entry map) -> (Or Array None)

Returns the `[key value]` pair with the largest key, or `()`.

ParameterTypeOptionalDescription
mapSorted-MaprequiredSorted-Map instance
Returns:Any
(sorted-map/last-entry m)

put#

function
(put map key value) -> Sorted-Map

Inserts or updates `key -> value` inside `Sorted-Map`.

ParameterTypeOptionalDescription
mapSorted-MaprequiredMutable map
keyAnyrequiredEntry key
valueAnyrequiredEntry value
Returns:Any
(m/put m :c 3)

remove#

function
(remove map key) -> Any

Removes `key` and returns its previous value (or `()`).

ParameterTypeOptionalDescription
mapSorted-MaprequiredMutable map
keyAnyrequiredKey to delete
Returns:Any
(m/remove m :a)

values-of#

function
(values-of map) -> Array

Returns all values matching key order as an Array.

ParameterTypeOptionalDescription
mapSorted-MaprequiredSorted-Map instance
Returns:Any
(values-of m)