forked from zapashcanon/hc
add Fake module
This commit is contained in:
parent
a9171be013
commit
6d6c40ee03
41
src/hc.ml
41
src/hc.ml
@ -19,33 +19,14 @@ module type Cache = sig
|
||||
|
||||
val clear : 'a t -> unit
|
||||
|
||||
val reset : 'a t -> unit
|
||||
|
||||
val copy : 'a t -> 'a t
|
||||
|
||||
val add : 'a t -> key -> 'a -> unit
|
||||
|
||||
val remove : 'a t -> key -> unit
|
||||
|
||||
val find : 'a t -> key -> 'a
|
||||
|
||||
val find_opt : 'a t -> key -> 'a option
|
||||
|
||||
val find_all : 'a t -> key -> 'a list
|
||||
|
||||
val replace : 'a t -> key -> 'a -> unit
|
||||
|
||||
val mem : 'a t -> key -> bool
|
||||
|
||||
val length : 'a t -> int
|
||||
|
||||
val stats : 'a t -> Hashtbl.statistics
|
||||
|
||||
val add_seq : 'a t -> (key * 'a) Seq.t -> unit
|
||||
|
||||
val replace_seq : 'a t -> (key * 'a) Seq.t -> unit
|
||||
|
||||
val of_seq : (key * 'a) Seq.t -> 'a t
|
||||
end
|
||||
|
||||
module Mk (Cache : Cache) : sig
|
||||
@ -92,3 +73,25 @@ end
|
||||
module MakeStrong (H : Hashtbl.HashedType) = struct
|
||||
include Mk (Hashtbl.Make (H))
|
||||
end
|
||||
|
||||
module Fake (H : Hashtbl.HashedType) = struct
|
||||
|
||||
include (Mk (struct
|
||||
type key = H.t
|
||||
type 'a t = | Unit
|
||||
|
||||
let create (_size : int) = Unit
|
||||
let clear Unit = ()
|
||||
let add (Unit : 'a t) (_v: key) (_ : 'a) = ()
|
||||
let find Unit (_v: key) = raise Not_found
|
||||
let length Unit = 0
|
||||
let stats Unit = {
|
||||
Hashtbl.num_bindings = 0;
|
||||
num_buckets = 0;
|
||||
max_bucket_length = 0;
|
||||
bucket_histogram = [||]
|
||||
}
|
||||
end
|
||||
))
|
||||
|
||||
end
|
||||
|
||||
@ -36,7 +36,7 @@ let rec get_fibo n =
|
||||
let b = get_fibo (n - 2) in
|
||||
node (extract a + extract b) a b
|
||||
|
||||
let _ =
|
||||
let () =
|
||||
(* 1 *)
|
||||
let n1 = leaf 1 in
|
||||
let n2 = leaf 2 in
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user