mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
27 lines
570 B
OCaml
27 lines
570 B
OCaml
(** An imperative cache of fixed size for memoization of pairs *)
|
|
|
|
module type S =
|
|
sig
|
|
type key
|
|
|
|
type 'a t
|
|
|
|
(** create a cache with given size *)
|
|
val create : int -> (key -> key -> 'a) -> 'a t
|
|
|
|
(** find a value in the cache *)
|
|
val lookup : 'a t -> key -> key -> 'a
|
|
|
|
(** clear the cache from its content *)
|
|
val clear : 'a t -> unit
|
|
end
|
|
|
|
module type CachedType =
|
|
sig
|
|
type t
|
|
val hash : t -> int
|
|
val equal : t -> t -> bool
|
|
end
|
|
|
|
(** functorial implementation *)
|
|
module Make(CType : CachedType) : S with type key = CType.t
|