mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
add CCHet.Tbl.{clear,reset}
This commit is contained in:
parent
cee2c7d8e3
commit
d4e582e829
3 changed files with 20 additions and 4 deletions
4
Makefile
4
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_VERSION/$(VERSION)/g" $(wildcard src/**/*.ml) $(wildcard src/**/*.mli)
|
||||||
sed -i "s/NEXT_RELEASE/$(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:
|
watch:
|
||||||
@dune build $(WATCH) -w
|
@dune build "$(WATCH)" -w
|
||||||
|
|
||||||
reindent:
|
reindent:
|
||||||
@which ocp-indent || ( echo "require ocp-indent" ; exit 1 )
|
@which ocp-indent || ( echo "require ocp-indent" ; exit 1 )
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,8 @@ module Tbl = struct
|
||||||
let to_list t = M.fold (fun _ p l -> pair_of_e_pair p :: l) t []
|
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_list t l = List.iter (add_pair_ t) l
|
||||||
let add_iter t seq = seq (add_pair_ t)
|
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 of_list l =
|
||||||
let t = create () in
|
let t = create () in
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
(* This file is free software, part of containers. See file "license" for more details. *)
|
|
||||||
|
|
||||||
(** Associative containers with Heterogeneous Values
|
(** Associative containers with Heterogeneous Values
|
||||||
|
|
||||||
This is similar to {!CCMixtbl}, but the injection is directly used as
|
This is similar to {!CCMixtbl}, but the injection is directly used as
|
||||||
|
|
@ -7,13 +5,21 @@
|
||||||
|
|
||||||
@since 0.17 *)
|
@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 iter = ('a -> unit) -> unit
|
||||||
type 'a gen = unit -> 'a option
|
type 'a gen = unit -> 'a option
|
||||||
|
|
||||||
|
(** Keys with a type witness. *)
|
||||||
module Key : sig
|
module Key : sig
|
||||||
type 'a t
|
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
|
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
|
val equal : 'a t -> 'a t -> bool
|
||||||
(** Compare two keys that have compatible types. *)
|
(** Compare two keys that have compatible types. *)
|
||||||
|
|
@ -32,6 +38,14 @@ module Tbl : sig
|
||||||
val length : t -> int
|
val length : t -> int
|
||||||
val find : t -> 'a Key.t -> 'a option
|
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
|
val find_exn : t -> 'a Key.t -> 'a
|
||||||
(** @raise Not_found if the key is not in the table. *)
|
(** @raise Not_found if the key is not in the table. *)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue