package tezos-protocol-019-PtParisB

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

A functor for building gas metered maps. When building a gas metered map via Make(G)(C), C is a COMPARABLE required to construct a the map while G is a module providing the gas consuming functions. The type of the context on which the gas consuming function operates is determined by G.context.

Parameters

module G : GAS
module C : COMPARABLE

Signature

type 'a t
type key = C.t

The type of keys in the map.

type context = G.context

The type used for the context.

val empty : 'a t

empty an empty map.

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

singleton k v returns a map with a single key k and value v pair.

val size : 'a t -> int

size m returns the number of elements of the map m in constant time.

find ctxt k m looks up the value with key k in the given map m and also consumes the gas associated with the lookup. The complexity is logarithmic in the size of the map.

update ctxt k f map updates or adds the value of the key k using f. The function accounts for the gas cost for finding the element. The updating function f should also account for its own gas cost. The complexity is logarithmic in the size of the map.

to_list m transforms a map m into a list. It also accounts for the gas cost for traversing the elements. The complexity is linear in the size of the map.

of_list ctxt ~merge_overlaps m creates a map from a list of key-value pairs. In case there are overlapping keys, their values are combined using the merge_overlap function. The function accounts for gas for traversing the elements. merge_overlap should account for its own gas cost. The complexity is n * log n in the size of the list.

merge ctxt ~merge_overlap m1 m2 merges the maps m1 and m2. In case there are overlapping keys, their values are combined using the merge_overlap function. Gas costs for traversing all elements from both maps are accounted for. merge_overlap should account for its own gas cost. The complexity is n * log n, where n is size m1 + size m2.

map_e ctxt f m maps over all key-value pairs in the map m using the function f. It accounts for gas costs associated with traversing the elements. The mapping function f should also account for its own gas cost. The complexity is linear in the size of the map m.

fold_e ctxt f z m folds over the key-value pairs of the given map m, accumulating values using f, with z as the initial state. The function f must account for its own gas cost. The complexity is linear in the size of the map m.

OCaml

Innovation. Community. Security.