1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556(**************************************************************************)(* *)(* Ocamlgraph: a generic graph library for OCaml *)(* Copyright (C) 2004-2010 *)(* Sylvain Conchon, Jean-Christophe Filliatre and Julien Signoles *)(* *)(* This software is free software; you can redistribute it and/or *)(* modify it under the terms of the GNU Library General Public *)(* License version 2.1, with the special exception on linking *)(* described in file LICENSE. *)(* *)(* This software is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *)(* *)(**************************************************************************)openSigmoduleOTProduct(X:ORDERED_TYPE)(Y:ORDERED_TYPE)=structtypet=X.t*Y.tletcompare(x1,y1)(x2,y2)=letcv=X.comparex1x2inifcv!=0thencvelseY.comparey1y2endmoduleHTProduct(X:HASHABLE)(Y:HASHABLE)=structtypet=X.t*Y.tletequal(x1,y1)(x2,y2)=X.equalx1x2&&Y.equaly1y2lethash(x,y)=Hashtbl.hash(X.hashx,Y.hashy)endmoduleCMPProduct(X:COMPARABLE)(Y:COMPARABLE)=structincludeHTProduct(X)(Y)include(OTProduct(X)(Y):sigvalcompare:t->t->intend)endmoduleDataV(L:sigtypetend)(V:Sig.COMPARABLE)=structtypedata=L.ttypelabel=V.ttypet=dataref*V.tletcompare(_,x)(_,x')=V.comparexx'lethash(_,x)=V.hashxletequal(_,x)(_,x')=V.equalxx'letcreateylbl=(refy,lbl)letlabel(_,z)=zletdata(y,_)=!yletset_data(y,_)=(:=)yendmoduleMemo(X:HASHABLE)=structmoduleH=Hashtbl.Make(X)letmemo?(size=128)f=leth=H.createsizeinfunx->tryH.findhxwithNot_found->lety=fxinH.addhxy;yend