tur/map

stdlib/map.tur
defn

map-new

(map-new :ptr<void>)

create a new empty map.

Since: Phase P3

defn

assoc

(assoc [m :ptr<void> key :ptr<void> val :ptr<void>] :ptr<void>)

insert or update a key/value pair; returns a new map.

msource map pointer
keykey pointer (hashed by pointer identity)
valvalue pointer

Since: Phase P3

defn

dissoc

(dissoc [m :ptr<void> key :ptr<void>] :ptr<void>)

remove a key from the map; returns a new map.

msource map pointer
keykey pointer to remove

Since: Phase P3

defn

get

(get [m :ptr<void> key :ptr<void>] :ptr<void>)

look up a key and return its value, or NULL if absent.

mmap pointer
keykey pointer to look up

Since: Phase P3

defn

has?

(has? [m :ptr<void> key :ptr<void>] :bool)

check whether a key exists in the map.

mmap pointer
keykey pointer to test

Since: Phase P3

defn

count

(count [m :ptr<void>] :int)

return the number of key/value pairs in the map.

mmap pointer

Since: Phase P3

defn

merge

(merge [a :ptr<void> b :ptr<void>] :ptr<void>)

merge two maps; values from b win on key collision.

afirst map pointer
bsecond map pointer (wins on collision)

Since: Phase P3

defn

map-eq?

(map-eq? [m1 m2 val-cmp] :bool)

compare two maps for structural equality using a value comparator.

m1first map pointer
m2second map pointer
val-cmpcomparator fn [a :int b :int] :bool applied to each value pair

Since: Phase P3