package fmlib_std

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

A map based on arrays

Parameters

Signature

include Interfaces.MAP with type key = Key.t
type key = Key.t

Type of the keys

type 'a t

Type of a map with keys of type key and values of type 'a.

val is_empty : 'a t -> bool

Is the map empty?

val cardinal : 'a t -> int

cardinal map The cardinality of the map i.e. the number of key value pairs in the map.

val fold_left : ('accu -> key -> 'a -> 'accu) -> 'accu -> 'a t -> 'accu

fold_left f start map

Fold the bindings in the map map from left to right i.e. lexically ascending using the start value start for the accumulator and the folding function f where f is applied f accue key value yielding a new accumulator by consuming one key value pair.

val fold_right : ('accu -> key -> 'a -> 'accu) -> 'accu -> 'a t -> 'accu

fold_left f start map

Fold the bindings in the map map from right to left i.e. lexically descending using the start value start for the accumulator and the folding function f where f is applied f accu key value yielding a new accumulator by consuming one key value pair.

val bindings : 'a t -> (key * 'a) list

The list of key value pairs in the map in ascending order.

val find_opt : key -> 'a t -> 'a option

find_opt key map

Find the value which is bound to the key key in the map map. Return None if no value is bound to key.

val empty : 'a t

The empty map.

val add : key -> 'a -> 'a t -> 'a t

add key value map Add the key value pair key, value to the map. If the map has already a key value pair with the key key then overwrite the old value with the new value.

val remove : key -> 'a t -> 'a t

remove key map Remove the key value pair with the key key from the map map. If the key is not present, then do nothing.

val update : key -> ('a option -> 'a option) -> 'a t -> 'a t

update key f map

Update the value bound to the key key in the map map by the update function f. If no value is bound to key then f None is called. If value is bound to key then f (Some value) is called.

If f returns None then no value is added and the old binding is deleted (if it existed before).

If f return Some new_value then the old value is updated, if existed, or the new value is added if no old value existed before.

val pair : int -> 'a t -> Key.t * 'a

pair i map The ith key value pair of map.

Precondition: 0 <= i && i < cardinal map

val singleton : Key.t -> 'a -> 'a t

singleton key value The map with the only key value pair (key,value).

OCaml

Innovation. Community. Security.