# Module type `M.S`

Signature of mutable LRU maps.

## Mutable LRU map

`type k`

Keys in

`t`

.

`type v`

Values in

`t`

.

`val create : ?random:bool -> int -> t`

`create ?random cap`

is a new map with capacity`cap`

.`~random`

randomizes the underlying hash table. It defaults to`false`

. See`Hashtbl`

.create.**Note.**The internal hash table is created with size`cap`

.- raises Invalid_argument
when

`cap < 0`

.

`val is_empty : t -> bool`

`is_empty t`

is`true`

iff there are no bindings in`t`

.

`val size : t -> int`

`size t`

is the number of bindings in`t`

.

## Limiting the weight of bindings

`val weight : t -> int`

`weight t`

is the combined weight of bindings in`t`

.

`val resize : int -> t -> unit`

`resize cap t`

sets`t`

's capacity to`cap`

, while leaving the bindings unchanged.- raises Invalid_argument
when

`cap < 0`

.

`val trim : t -> unit`

`trim t`

ensures that`weight t <= capacity t`

by dropping bindings in LRU-to-MRU order.

## Access by `k`

`val find : k -> t -> v option`

`find k t`

is`Some v`

when`k -> v`

is bound in`t`

, or`None`

otherwise.**Note**This operation does not change the recently-used order.

`val promote : k -> t -> unit`

`promote k t`

promotes the binding for`k`

, if it exists, to most-recently-used.

## Access to least-recently-used bindings

`val lru : t -> (k * v) option`

`lru t`

is the least-recently-used binding in`t`

, or`None`

, when`t`

is empty.

`val drop_lru : t -> unit`

`drop_lru t`

removes the binding`lru t`

.

## Aggregate access

## Conversions

## Pretty-printing

`val pp : ?pp_size:(Stdlib.Format.formatter -> (int * int) -> unit) -> ?sep:(Stdlib.Format.formatter -> unit -> unit) -> (Stdlib.Format.formatter -> (k * v) -> unit) -> Stdlib.Format.formatter -> t -> unit`

`pp ~pp_size ~sep pp_kv ppf t`

pretty-prints`t`

to`ppf`

, using`pp_kv`

to print the bindings,`~sep`

to separate them, and`~pp_size`

to print the`weight`

and`capacity`

.`~sep`

and`~pp_size`

default to unspecified printers.