package fmlib_std
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=17d85e2ca14a57f7c7292f5cb53db1da63044487b5149cf366ea76db92b55818
md5=dd0b8db1f0de867708797cfbc471d652
doc/fmlib_std/Fmlib_std/Btree/Map/index.html
Module Btree.Map
A finite map implemented by a B tree.
Parameters
module Key : Interfaces.SORTABLESignature
Map API
include Interfaces.MAP with type key = Key.t
type key = Key.tType of the keys
val is_empty : 'a t -> boolIs the map empty?
val cardinal : 'a t -> intcardinal map The cardinality of the map i.e. the number of key value pairs in the map.
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.
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.
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 tThe empty map.
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.
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.
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.
Stream of key value pairs
All key value pairs of a finite map can be considered as a sorted list of key value pairs. It is possible to iterate over this sequence with the help of the function fold_left. However this function performs the whole iteration.
Sometimes it is desirable to iterate over the sequence of the sorted key value pairs and keep the control over the iteration. For that purpose it is convenient to have the finite map as a stream of key value pairs.
val has_more : 'a source -> boolHas the stream of key value pairs more elements?
advances source Advance the stream by one element.
Precondition: has_more source
module Source (Value : Interfaces.ANY) : sig ... endModule which satisfies the interface Interfaces.SOURCE