package containers

  1. Overview
  2. Docs
A modular, clean and powerful extension of the OCaml standard library

Install

Dune Dependency

Authors

Maintainers

Sources

v2.8.1.tar.gz
md5=d84e09c5d0abc501aa17cd502e31a038
sha512=8b832f4ada6035e80d81be0cfb7bdffb695ec67d465ed6097a144019e2b8a8f909095e78019c3da2d8181cc3cd730cd48f7519e87d3162442562103b7f36aabb

doc/containers.data/CCMixset/index.html

Module CCMixsetSource

Set of Heterogeneous Values

  let k1 : int key = newkey () in
  let k2 : int key = newkey () in
  let k3 : string key = newkey () in
  let set =
    empty
    |> set ~key:k1 1
    |> set ~key:k2 2
    |> set ~key:k3 "3"
  in
  assert (get ~key:k1 set = Some 1);
  assert (get ~key:k2 set = Some 2);
  assert (get ~key:k3 set = Some "3");
  ()
  • since 0.11
Sourcetype t

A set of values of heterogeneous types

Sourcetype 'a key

A unique "key" to access a value of type 'a in a set

Sourceval newkey : unit -> 'a key

newkey () creates a new unique key that can be used to access a 'a value in a set. Each key created with newkey is distinct from any other key, even if they have the same type.

Not thread-safe.

Sourceval empty : t

Empty set.

Sourceval set : key:'a key -> 'a -> t -> t

set ~key v set maps key to v in set. It means that for every set, get ~key (set ~key v set) = Some v.

Sourceval get : key:'a key -> t -> 'a option

get ~key set obtains the value for key in set, if any.

Sourceval get_exn : key:'a key -> t -> 'a

Same as get, but can fail.

Sourceval cardinal : t -> int

Number of mappings.

OCaml

Innovation. Community. Security.