Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file Heap.ml
12345678910111213141516171819202122232425262728293031323334353637type'at={tree:'atree;cmp:'a->'a->int;merge:'a->'a->'a;}(** A pairing tree heap with the given comparison function *)and'atree=|Empty|Nodeof'a*'atree*'atreeletempty~cmp~merge={tree=Empty;cmp;merge;}letis_emptyh=matchh.treewith|Empty->true|Node_->falseletrecunion({cmp;merge;_}ash)t1t2=matcht1,t2with|Empty,_->t2|_,Empty->t1|Node(x1,l1,r1),Node(x2,l2,r2)->letc=cmpx1x2inifc=0thenNode(mergex1x2,unionhr1r2,unionhl1l2)elseifc<0thenNode(x1,unionht2r1,l1)elseNode(x2,unionht1r2,l2)letinserthx={hwithtree=unionh(Node(x,Empty,Empty))h.tree}letpoph=matchh.treewith|Empty->raiseNot_found|Node(x,l,r)->x,{hwithtree=unionhlr}