blob: 43a5eb15b40dbacf79ec2bbe7df4425af3da8f20 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
(* $Id$ *)
class ['a,'b] c fun:(f : 'a -> 'b) = object
val hash = Hashtbl.create 7
method get key =
try Hashtbl.find hash :key
with Not_found ->
let data = f key in
Hashtbl.add hash :key :data;
data
method clear = Hashtbl.clear hash
method reget key =
Hashtbl.remove :key hash;
let data = f key in
Hashtbl.add hash :key :data;
data
end
|