module CCMixtbl:sig
..end
From https://github.com/mjambon/mixtbl (thanks to him). Example:
let inj_int = CCMixtbl.create_inj () ;;
let tbl = CCMixtbl.create 10 ;;
OUnit.assert_equal None (CCMixtbl.get ~inj:inj_int tbl "a");;
CCMixtbl.set inj_int tbl "a" 1;;
OUnit.assert_equal (Some 1) (CCMixtbl.get ~inj:inj_int tbl "a");;
let inj_string = CCMixtbl.create_inj () ;;
CCMixtbl.set inj_string tbl "b" "Hello";
OUnit.assert_equal (Some "Hello") (CCMixtbl.get inj_string tbl "b");;
OUnit.assert_equal None (CCMixtbl.get inj_string tbl "a");;
OUnit.assert_equal (Some 1) (CCMixtbl.get inj_int tbl "a");;
CCMixtbl.set inj_string tbl "a" "Bye";;
OUnit.assert_equal None (CCMixtbl.get inj_int tbl "a");;
OUnit.assert_equal (Some "Bye") (CCMixtbl.get inj_string tbl "a");;
type 'a
t
'a
represents the type of the keys.type 'b
injection
val create : int -> 'a t
create n
creates a hash table of initial size n
.val create_inj : unit -> 'b injection
val get : inj:'b injection -> 'a t -> 'a -> 'b option
val set : inj:'b injection -> 'a t -> 'a -> 'b -> unit
inj
val find : inj:'b injection -> 'a t -> 'a -> 'b
Not_found
if either the key is not found, or if its value
doesn't belong to the right typeval length : 'a t -> int
val clear : 'a t -> unit
val remove : 'a t -> 'a -> unit
val copy : 'a t -> 'a t
val mem : inj:'b injection -> 'a t -> 'a -> bool
val iter_keys : 'a t -> ('a -> unit) -> unit
val fold_keys : 'a t -> 'b -> ('b -> 'a -> 'b) -> 'b
type'a
sequence =('a -> unit) -> unit
val keys_seq : 'a t -> 'a sequence
val bindings_of : inj:'b injection -> 'a t -> ('a * 'b) sequence
type
value =
| |
Value : |
val bindings : 'a t -> ('a * value) sequence