diff --git a/Makefile b/Makefile index 600c94ca..d874f3df 100644 --- a/Makefile +++ b/Makefile @@ -30,9 +30,9 @@ update_next_tag: sed -i "s/NEXT_VERSION/$(VERSION)/g" $(wildcard src/**/*.ml) $(wildcard src/**/*.mli) sed -i "s/NEXT_RELEASE/$(VERSION)/g" $(wildcard src/**/*.ml) $(wildcard src/**/*.mli) -WATCH?=@all +WATCH?="@src/all @tests/runtest" watch: - @dune build $(WATCH) -w + @dune build "$(WATCH)" -w reindent: @which ocp-indent || ( echo "require ocp-indent" ; exit 1 ) diff --git a/src/data/CCHet.ml b/src/data/CCHet.ml index 053619a3..1f544db7 100644 --- a/src/data/CCHet.ml +++ b/src/data/CCHet.ml @@ -85,6 +85,8 @@ module Tbl = struct let to_list t = M.fold (fun _ p l -> pair_of_e_pair p :: l) t [] let add_list t l = List.iter (add_pair_ t) l let add_iter t seq = seq (add_pair_ t) + let clear t = M.clear t + let reset t = M.reset t let of_list l = let t = create () in diff --git a/src/data/CCHet.mli b/src/data/CCHet.mli index 14f95b67..70b35354 100644 --- a/src/data/CCHet.mli +++ b/src/data/CCHet.mli @@ -1,5 +1,3 @@ -(* This file is free software, part of containers. See file "license" for more details. *) - (** Associative containers with Heterogeneous Values This is similar to {!CCMixtbl}, but the injection is directly used as @@ -7,13 +5,21 @@ @since 0.17 *) +(* This file is free software, part of containers. See file "license" for more details. *) + type 'a iter = ('a -> unit) -> unit type 'a gen = unit -> 'a option +(** Keys with a type witness. *) module Key : sig type 'a t + (** A key of type ['a t] is used to access the portion of the + map or table that associates keys of type ['a] to values. *) val create : unit -> 'a t + (** Make a new key. This is generative, so calling [create ()] twice with the + same return type will produce incompatible keys that cannot see each + other's bindings. *) val equal : 'a t -> 'a t -> bool (** Compare two keys that have compatible types. *) @@ -32,6 +38,14 @@ module Tbl : sig val length : t -> int val find : t -> 'a Key.t -> 'a option + val clear : t -> unit + (** clear the table (like {!Hashtbl.clear}) + @since NEXT_RELEASE *) + + val reset : t -> unit + (** reset the table (like {!Hashtbl.reset}) + @since NEXT_RELEASE *) + val find_exn : t -> 'a Key.t -> 'a (** @raise Not_found if the key is not in the table. *)