mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
wip: Mixset
This commit is contained in:
parent
5208579b9d
commit
b66caf67bf
2 changed files with 15 additions and 1 deletions
|
|
@ -75,3 +75,5 @@ let get_exn ~key set = match get ~key set with
|
|||
|
||||
let set ~key v set =
|
||||
IMap.add key.id (fun () -> key.opt <- Some v) set
|
||||
|
||||
let cardinal set = IMap.cardinal set
|
||||
|
|
|
|||
|
|
@ -52,14 +52,26 @@ type 'a key
|
|||
|
||||
val newkey : unit -> 'a key
|
||||
(** [newkey ()] creates a new unique key that can be used to access
|
||||
a ['a] value in a set *)
|
||||
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. *)
|
||||
|
||||
val empty : t
|
||||
(** Empty set *)
|
||||
|
||||
val 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]. *)
|
||||
|
||||
val get : key:'a key -> t -> 'a option
|
||||
(** [get ~key set] obtains the value for [key] in [set], if any. *)
|
||||
|
||||
val get_exn : key:'a key -> t -> 'a
|
||||
(** Same as {!get}, but can fail
|
||||
@raise Not_found if the key is not present *)
|
||||
|
||||
val cardinal : t -> int
|
||||
(** Number of mappings *)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue