mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-18 16:46:40 -05:00
Remove CCCache.default_eq_
This commit is contained in:
parent
d15a41fa3f
commit
37956bccea
3 changed files with 15 additions and 16 deletions
|
|
@ -366,16 +366,16 @@ module Cache = struct
|
||||||
|
|
||||||
let bench_fib n =
|
let bench_fib n =
|
||||||
let l =
|
let l =
|
||||||
[ "replacing_fib (128)", make_fib (C.replacing 128), n
|
[ "replacing_fib (128)", make_fib (C.replacing ~eq:CCInt.equal 128), n
|
||||||
; "LRU_fib (128)", make_fib (C.lru 128), n
|
; "LRU_fib (128)", make_fib (C.lru ~eq:CCInt.equal 128), n
|
||||||
; "replacing_fib (16)", make_fib (C.replacing 16), n
|
; "replacing_fib (16)", make_fib (C.replacing ~eq:CCInt.equal 16), n
|
||||||
; "LRU_fib (16)", make_fib (C.lru 16), n
|
; "LRU_fib (16)", make_fib (C.lru ~eq:CCInt.equal 16), n
|
||||||
; "unbounded", make_fib (C.unbounded 32), n
|
; "unbounded", make_fib (C.unbounded ~eq:CCInt.equal 32), n
|
||||||
]
|
]
|
||||||
in
|
in
|
||||||
let l = if n <= 20
|
let l = if n <= 20
|
||||||
then [ "linear_fib (5)", make_fib (C.linear 5), n
|
then [ "linear_fib (5)", make_fib (C.linear ~eq:CCInt.equal 5), n
|
||||||
; "linear_fib (32)", make_fib (C.linear 32), n
|
; "linear_fib (32)", make_fib (C.linear ~eq:CCInt.equal 32), n
|
||||||
; "dummy_fib", make_fib C.dummy, n
|
; "dummy_fib", make_fib C.dummy, n
|
||||||
] @ l
|
] @ l
|
||||||
else l
|
else l
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
type 'a equal = 'a -> 'a -> bool
|
type 'a equal = 'a -> 'a -> bool
|
||||||
type 'a hash = 'a -> int
|
type 'a hash = 'a -> int
|
||||||
|
|
||||||
let default_eq_ = Pervasives.(=)
|
|
||||||
let default_hash_ = Hashtbl.hash
|
let default_hash_ = Hashtbl.hash
|
||||||
|
|
||||||
(** {2 Value interface} *)
|
(** {2 Value interface} *)
|
||||||
|
|
@ -124,7 +123,7 @@ module Linear = struct
|
||||||
!r
|
!r
|
||||||
end
|
end
|
||||||
|
|
||||||
let linear ?(eq=default_eq_) size =
|
let linear ~eq size =
|
||||||
let size = max size 1 in
|
let size = max size 1 in
|
||||||
let arr = Linear.make eq size in
|
let arr = Linear.make eq size in
|
||||||
{ get=(fun x -> Linear.get arr x);
|
{ get=(fun x -> Linear.get arr x);
|
||||||
|
|
@ -176,7 +175,7 @@ module Replacing = struct
|
||||||
let size c () = c.c_size
|
let size c () = c.c_size
|
||||||
end
|
end
|
||||||
|
|
||||||
let replacing ?(eq=default_eq_) ?(hash=default_hash_) size =
|
let replacing ~eq ?(hash=default_hash_) size =
|
||||||
let c = Replacing.make eq hash size in
|
let c = Replacing.make eq hash size in
|
||||||
{ get=(fun x -> Replacing.get c x);
|
{ get=(fun x -> Replacing.get c x);
|
||||||
set=(fun x y -> Replacing.set c x y);
|
set=(fun x y -> Replacing.set c x y);
|
||||||
|
|
@ -298,7 +297,7 @@ module LRU(X:HASH) = struct
|
||||||
H.iter (fun x node -> f x node.value) c.table
|
H.iter (fun x node -> f x node.value) c.table
|
||||||
end
|
end
|
||||||
|
|
||||||
let lru (type a) ?(eq=default_eq_) ?(hash=default_hash_) size =
|
let lru (type a) ~eq ?(hash=default_hash_) size =
|
||||||
let module L = LRU(struct
|
let module L = LRU(struct
|
||||||
type t = a
|
type t = a
|
||||||
let equal = eq
|
let equal = eq
|
||||||
|
|
@ -360,7 +359,7 @@ module UNBOUNDED(X:HASH) = struct
|
||||||
let iter c f = H.iter f c
|
let iter c f = H.iter f c
|
||||||
end
|
end
|
||||||
|
|
||||||
let unbounded (type a) ?(eq=default_eq_) ?(hash=default_hash_) size =
|
let unbounded (type a) ~eq ?(hash=default_hash_) size =
|
||||||
let module C = UNBOUNDED(struct
|
let module C = UNBOUNDED(struct
|
||||||
type t = a
|
type t = a
|
||||||
let equal = eq
|
let equal = eq
|
||||||
|
|
|
||||||
|
|
@ -79,13 +79,13 @@ val add : ('a, 'b) t -> 'a -> 'b -> bool
|
||||||
val dummy : ('a,'b) t
|
val dummy : ('a,'b) t
|
||||||
(** Dummy cache, never stores any value *)
|
(** Dummy cache, never stores any value *)
|
||||||
|
|
||||||
val linear : ?eq:'a equal -> int -> ('a, 'b) t
|
val linear : eq:'a equal -> int -> ('a, 'b) t
|
||||||
(** Linear cache with the given size. It stores key/value pairs in
|
(** Linear cache with the given size. It stores key/value pairs in
|
||||||
an array and does linear search at every call, so it should only be used
|
an array and does linear search at every call, so it should only be used
|
||||||
with small size.
|
with small size.
|
||||||
@param eq optional equality predicate for keys *)
|
@param eq optional equality predicate for keys *)
|
||||||
|
|
||||||
val replacing : ?eq:'a equal -> ?hash:'a hash ->
|
val replacing : eq:'a equal -> ?hash:'a hash ->
|
||||||
int -> ('a,'b) t
|
int -> ('a,'b) t
|
||||||
(** Replacing cache of the given size. Equality and hash functions can be
|
(** Replacing cache of the given size. Equality and hash functions can be
|
||||||
parametrized. It's a hash table that handles collisions by replacing
|
parametrized. It's a hash table that handles collisions by replacing
|
||||||
|
|
@ -93,12 +93,12 @@ val replacing : ?eq:'a equal -> ?hash:'a hash ->
|
||||||
entry with the same hash (modulo size) is added).
|
entry with the same hash (modulo size) is added).
|
||||||
Never grows wider than the given size. *)
|
Never grows wider than the given size. *)
|
||||||
|
|
||||||
val lru : ?eq:'a equal -> ?hash:'a hash ->
|
val lru : eq:'a equal -> ?hash:'a hash ->
|
||||||
int -> ('a,'b) t
|
int -> ('a,'b) t
|
||||||
(** LRU cache of the given size ("Least Recently Used": keys that have not been
|
(** LRU cache of the given size ("Least Recently Used": keys that have not been
|
||||||
used recently are deleted first). Never grows wider than the given size. *)
|
used recently are deleted first). Never grows wider than the given size. *)
|
||||||
|
|
||||||
val unbounded : ?eq:'a equal -> ?hash:'a hash ->
|
val unbounded : eq:'a equal -> ?hash:'a hash ->
|
||||||
int -> ('a,'b) t
|
int -> ('a,'b) t
|
||||||
(** Unbounded cache, backed by a Hash table. Will grow forever
|
(** Unbounded cache, backed by a Hash table. Will grow forever
|
||||||
unless {!clear} is called manually. *)
|
unless {!clear} is called manually. *)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue