mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-07 19:55:31 -05:00
document some invariants in CCCache (see #38)
This commit is contained in:
parent
438c57e847
commit
9d2e369732
1 changed files with 7 additions and 0 deletions
|
|
@ -33,6 +33,13 @@ let default_hash_ = Hashtbl.hash
|
||||||
|
|
||||||
(** {2 Value interface} *)
|
(** {2 Value interface} *)
|
||||||
|
|
||||||
|
(** Invariants:
|
||||||
|
- after [cache.set x y], [get cache x] must return [y] or raise [Not_found]
|
||||||
|
- [cache.set x y] is only called if [get cache x] fails, never if [x] is already bound
|
||||||
|
- [cache.size()] must be positive and correspond to the number of items in [cache.iter]
|
||||||
|
- [cache.iter f] calls [f x y] with every [x] such that [cache.get x = y]
|
||||||
|
- after [cache.clear()], [cache.get x] fails for every [x]
|
||||||
|
*)
|
||||||
type ('a,'b) t = {
|
type ('a,'b) t = {
|
||||||
set : 'a -> 'b -> unit;
|
set : 'a -> 'b -> unit;
|
||||||
get : 'a -> 'b; (* or raise Not_found *)
|
get : 'a -> 'b; (* or raise Not_found *)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue