temochka / enclojure / Enclojure.ValueKeyMap

Represents a dictionary-like type where the keys are Enclojure values and values are arbitrary Elm types. Used internally by ValueMap io.

Creating


type alias ValueKeyMap io v =
Enclojure.Common.ValueMap io v

Represents a map of values to v. Operation complexity depends on the type of the key. For keywords, symbols, strings, floats, and integers, the complexity of insert/remove operations is logarithmic. For other value types, the complexity ranges from linear or worse, depending on the type of key values.


type alias ValueKeyMapEntry io v =
Enclojure.Common.ValueMapEntry io v

Represents a map entry.

empty : ValueKeyMap io v

Returns an empty map.

fromList : List (ValueKeyMapEntry io v) -> ValueKeyMap io v

Creates a map from a given list of map entries.

Accessing values

get : Enclojure.Common.Value io -> ValueKeyMap io v -> Maybe v

Returns the value at a given key in the map if present.

keys : ValueKeyMap io v -> List (Enclojure.Common.Value io)

Returns the list of map keys.

values : ValueKeyMap io v -> List v

Returns the list of map values

toList : ValueKeyMap io v -> List (ValueKeyMapEntry io v)

Transforms a given map into a list of map entries.

Modifying

foldl : (Enclojure.Common.Value io -> v -> a -> a) -> a -> ValueKeyMap io v -> a

Folds a given map from left to right using a function that accepts the key, the value, and the accumulator, and is called for each entry in the map.

insert : Enclojure.Common.Value io -> v -> ValueKeyMap io v -> Enclojure.Common.ValueMap io v

Inserts a value specified by the second argument to the key specified by the first argument.

map : (ValueKeyMapEntry io v -> ValueKeyMapEntry io v) -> ValueKeyMap io v -> ValueKeyMap io v

Applies a function to every mapEntry in the map.

remove : Enclojure.Common.Value io -> ValueKeyMap io v -> ValueKeyMap io v

Removes the value at a given key from the map.

Predicates

isEmpty : ValueKeyMap io v -> Basics.Bool

Returns True if the map is empty.

member : Enclojure.Common.Value io -> ValueKeyMap io v -> Basics.Bool

Returns True if the map has a value at a given key.