123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384moduletypeS=Set_intf.SmoduleMake(Key:Map_intf.Key)(M:Map_intf.Swithtypekey=Key.t)=structmoduleT=Dune_caml.MoreLabels.Set.Make(structtypet=Key.tletcomparexy=Ordering.to_int(Key.comparexy)end)includestruct[@@@warning"-32"](* [map] is only available since 4.04 *)letmap~ft=T.elementst|>List.map~f|>T.of_list(* Since 4.05 *)letto_optft=matchftwith|x->Somex|exceptionNot_found->Noneletchoose_opt=to_optT.chooseletmin_elt_opt=to_optT.min_eltletmax_elt_opt=to_optT.max_eltendtype'amap='aM.tletto_list=T.elementsincludeTletmemtx=memxtletaddtx=addxtletremovetx=removextletcompareab=Ordering.of_int(compareab)letis_subsett~of_=subsettof_letitert~f=itert~fletmapt~f=mapt~fletfoldt~init~f=foldt~init~fletfor_allt~f=for_allt~fletexistst~f=existst~fletfiltert~f=filtert~fletpartitiont~f=partitiont~fletmin_elt=min_elt_optletmax_elt=max_elt_optletchoose=choose_optletsplitxt=splittxletunion_mapl~f=List.fold_left~init:emptyl~f:(funaccx->lets=fxinunionaccs)letunion_alll=union_mapl~f:(funx->x)exceptionFoundofeltletfindt~f=matchitert~f:(fune->iffethenraise_notrace(Founde)else())with|()->None|exception(Founde)->Someeletto_dynt=Dyn.Set(to_listt|>List.map~f:Key.to_dyn)letchoose_exnt=matchchoosetwith|Somee->e|None->Code_error.raise"Set.choose_exn"["t",to_dynt]letof_keys=M.foldi~init:empty~f:(funk_acc->addacck)letto_map=fold~init:M.empty~f:(funkacc->M.setacck())end