12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033open!Importopen!TmoduleOr_duplicate=structtype'at=[`Okof'a|`Duplicate][@@deriving_inlinecompare,equal,sexp_of]letcompare:'a.('a->'a->int)->'at->'at->int=fun_cmp__aa__001_b__002_->ifStdlib.(==)a__001_b__002_then0else(matcha__001_,b__002_with|`Ok_left__003_,`Ok_right__004_->_cmp__a_left__003__right__004_|`Duplicate,`Duplicate->0|x,y->Stdlib.comparexy);;letequal:'a.('a->'a->bool)->'at->'at->bool=fun_cmp__aa__005_b__006_->ifStdlib.(==)a__005_b__006_thentrueelse(matcha__005_,b__006_with|`Ok_left__007_,`Ok_right__008_->_cmp__a_left__007__right__008_|`Duplicate,`Duplicate->true|x,y->Stdlib.(=)xy);;letsexp_of_t:'a.('a->Sexplib0.Sexp.t)->'at->Sexplib0.Sexp.t=fun_of_a__009_->function|`Okv__010_->Sexplib0.Sexp.List[Sexplib0.Sexp.Atom"Ok";_of_a__009_v__010_]|`Duplicate->Sexplib0.Sexp.Atom"Duplicate";;[@@@end]endmoduleWithout_comparator=structtype('key,'cmp,'z)t='zendmoduleWith_comparator=structtype('key,'cmp,'z)t=comparator:('key,'cmp)Comparator.t->'zendmoduleWith_first_class_module=structtype('key,'cmp,'z)t=('key,'cmp)Comparator.Module.t->'zendmoduleSymmetric_diff_element=structtype('k,'v)t='k*[`Leftof'v|`Rightof'v|`Unequalof'v*'v][@@deriving_inlinecompare,equal,sexp,sexp_grammar]letcompare:'k'v.('k->'k->int)->('v->'v->int)->('k,'v)t->('k,'v)t->int=fun_cmp__k_cmp__va__011_b__012_->lett__013_,t__014_=a__011_inlett__015_,t__016_=b__012_inmatch_cmp__kt__013_t__015_with|0->ifStdlib.(==)t__014_t__016_then0else(matcht__014_,t__016_with|`Left_left__017_,`Left_right__018_->_cmp__v_left__017__right__018_|`Right_left__019_,`Right_right__020_->_cmp__v_left__019__right__020_|`Unequal_left__021_,`Unequal_right__022_->lett__023_,t__024_=_left__021_inlett__025_,t__026_=_right__022_in(match_cmp__vt__023_t__025_with|0->_cmp__vt__024_t__026_|n->n)|x,y->Stdlib.comparexy)|n->n;;letequal:'k'v.('k->'k->bool)->('v->'v->bool)->('k,'v)t->('k,'v)t->bool=fun_cmp__k_cmp__va__027_b__028_->lett__029_,t__030_=a__027_inlett__031_,t__032_=b__028_inStdlib.(&&)(_cmp__kt__029_t__031_)(ifStdlib.(==)t__030_t__032_thentrueelse(matcht__030_,t__032_with|`Left_left__033_,`Left_right__034_->_cmp__v_left__033__right__034_|`Right_left__035_,`Right_right__036_->_cmp__v_left__035__right__036_|`Unequal_left__037_,`Unequal_right__038_->lett__039_,t__040_=_left__037_inlett__041_,t__042_=_right__038_inStdlib.(&&)(_cmp__vt__039_t__041_)(_cmp__vt__040_t__042_)|x,y->Stdlib.(=)xy));;lett_of_sexp:'k'v.(Sexplib0.Sexp.t->'k)->(Sexplib0.Sexp.t->'v)->Sexplib0.Sexp.t->('k,'v)t=leterror_source__057_="map_intf.ml.Symmetric_diff_element.t"infun_of_k__043__of_v__044_->function|Sexplib0.Sexp.List[arg0__067_;arg1__068_]->letres0__069_=_of_k__043_arg0__067_andres1__070_=letsexp__066_=arg1__068_intrymatchsexp__066_with|Sexplib0.Sexp.Atomatom__047_as_sexp__049_->(matchatom__047_with|"Left"->Sexplib0.Sexp_conv_error.ptag_takes_argserror_source__057__sexp__049_|"Right"->Sexplib0.Sexp_conv_error.ptag_takes_argserror_source__057__sexp__049_|"Unequal"->Sexplib0.Sexp_conv_error.ptag_takes_argserror_source__057__sexp__049_|_->Sexplib0.Sexp_conv_error.no_variant_match())|Sexplib0.Sexp.List(Sexplib0.Sexp.Atomatom__047_::sexp_args__050_)as_sexp__049_->(matchatom__047_with|"Left"as_tag__063_->(matchsexp_args__050_with|[arg0__064_]->letres0__065_=_of_v__044_arg0__064_in`Leftres0__065_|_->Sexplib0.Sexp_conv_error.ptag_incorrect_n_argserror_source__057__tag__063__sexp__049_)|"Right"as_tag__060_->(matchsexp_args__050_with|[arg0__061_]->letres0__062_=_of_v__044_arg0__061_in`Rightres0__062_|_->Sexplib0.Sexp_conv_error.ptag_incorrect_n_argserror_source__057__tag__060__sexp__049_)|"Unequal"as_tag__051_->(matchsexp_args__050_with|[arg0__058_]->letres0__059_=matcharg0__058_with|Sexplib0.Sexp.List[arg0__052_;arg1__053_]->letres0__054_=_of_v__044_arg0__052_andres1__055_=_of_v__044_arg1__053_inres0__054_,res1__055_|sexp__056_->Sexplib0.Sexp_conv_error.tuple_of_size_n_expectederror_source__057_2sexp__056_in`Unequalres0__059_|_->Sexplib0.Sexp_conv_error.ptag_incorrect_n_argserror_source__057__tag__051__sexp__049_)|_->Sexplib0.Sexp_conv_error.no_variant_match())|Sexplib0.Sexp.List(Sexplib0.Sexp.List_::_)assexp__048_->Sexplib0.Sexp_conv_error.nested_list_invalid_poly_varerror_source__057_sexp__048_|Sexplib0.Sexp.List[]assexp__048_->Sexplib0.Sexp_conv_error.empty_list_invalid_poly_varerror_source__057_sexp__048_with|Sexplib0.Sexp_conv_error.No_variant_match->Sexplib0.Sexp_conv_error.no_matching_variant_founderror_source__057_sexp__066_inres0__069_,res1__070_|sexp__071_->Sexplib0.Sexp_conv_error.tuple_of_size_n_expectederror_source__057_2sexp__071_;;letsexp_of_t:'k'v.('k->Sexplib0.Sexp.t)->('v->Sexplib0.Sexp.t)->('k,'v)t->Sexplib0.Sexp.t=fun_of_k__072__of_v__073_(arg0__081_,arg1__082_)->letres0__083_=_of_k__072_arg0__081_andres1__084_=matcharg1__082_with|`Leftv__074_->Sexplib0.Sexp.List[Sexplib0.Sexp.Atom"Left";_of_v__073_v__074_]|`Rightv__075_->Sexplib0.Sexp.List[Sexplib0.Sexp.Atom"Right";_of_v__073_v__075_]|`Unequalv__076_->Sexplib0.Sexp.List[Sexplib0.Sexp.Atom"Unequal";(letarg0__077_,arg1__078_=v__076_inletres0__079_=_of_v__073_arg0__077_andres1__080_=_of_v__073_arg1__078_inSexplib0.Sexp.List[res0__079_;res1__080_])]inSexplib0.Sexp.List[res0__083_;res1__084_];;lett_sexp_grammar:'k'v.'kSexplib0.Sexp_grammar.t->'vSexplib0.Sexp_grammar.t->('k,'v)tSexplib0.Sexp_grammar.t=fun_'k_sexp_grammar_'v_sexp_grammar->{untyped=List(Cons(_'k_sexp_grammar.untyped,Cons(Variant{case_sensitivity=Case_sensitive;clauses=[No_tag{name="Left";clause_kind=List_clause{args=Cons(_'v_sexp_grammar.untyped,Empty)}};No_tag{name="Right";clause_kind=List_clause{args=Cons(_'v_sexp_grammar.untyped,Empty)}};No_tag{name="Unequal";clause_kind=List_clause{args=Cons(List(Cons(_'v_sexp_grammar.untyped,Cons(_'v_sexp_grammar.untyped,Empty))),Empty)}}]},Empty)))};;[@@@end]endmoduleMerge_element=structtype('left,'right)t=[`Leftof'left|`Rightof'right|`Bothof'left*'right][@@deriving_inlinecompare,equal,sexp_of]letcompare:'left'right.('left->'left->int)->('right->'right->int)->('left,'right)t->('left,'right)t->int=fun_cmp__left_cmp__righta__085_b__086_->ifStdlib.(==)a__085_b__086_then0else(matcha__085_,b__086_with|`Left_left__087_,`Left_right__088_->_cmp__left_left__087__right__088_|`Right_left__089_,`Right_right__090_->_cmp__right_left__089__right__090_|`Both_left__091_,`Both_right__092_->lett__093_,t__094_=_left__091_inlett__095_,t__096_=_right__092_in(match_cmp__leftt__093_t__095_with|0->_cmp__rightt__094_t__096_|n->n)|x,y->Stdlib.comparexy);;letequal:'left'right.('left->'left->bool)->('right->'right->bool)->('left,'right)t->('left,'right)t->bool=fun_cmp__left_cmp__righta__097_b__098_->ifStdlib.(==)a__097_b__098_thentrueelse(matcha__097_,b__098_with|`Left_left__099_,`Left_right__100_->_cmp__left_left__099__right__100_|`Right_left__101_,`Right_right__102_->_cmp__right_left__101__right__102_|`Both_left__103_,`Both_right__104_->lett__105_,t__106_=_left__103_inlett__107_,t__108_=_right__104_inStdlib.(&&)(_cmp__leftt__105_t__107_)(_cmp__rightt__106_t__108_)|x,y->Stdlib.(=)xy);;letsexp_of_t:'left'right.('left->Sexplib0.Sexp.t)->('right->Sexplib0.Sexp.t)->('left,'right)t->Sexplib0.Sexp.t=fun_of_left__109__of_right__110_->function|`Leftv__111_->Sexplib0.Sexp.List[Sexplib0.Sexp.Atom"Left";_of_left__109_v__111_]|`Rightv__112_->Sexplib0.Sexp.List[Sexplib0.Sexp.Atom"Right";_of_right__110_v__112_]|`Bothv__113_->Sexplib0.Sexp.List[Sexplib0.Sexp.Atom"Both";(letarg0__114_,arg1__115_=v__113_inletres0__116_=_of_left__109_arg0__114_andres1__117_=_of_right__110_arg1__115_inSexplib0.Sexp.List[res0__116_;res1__117_])];;[@@@end]end(** @canonical Base.Map.Continue_or_stop *)moduleContinue_or_stop=structtypet=|Continue|Stop[@@deriving_inlinecompare,enumerate,equal,sexp_of]letcompare=(Stdlib.compare:t->t->int)letall=([Continue;Stop]:tlist)letequal=(Stdlib.(=):t->t->bool)letsexp_of_t=(function|Continue->Sexplib0.Sexp.Atom"Continue"|Stop->Sexplib0.Sexp.Atom"Stop":t->Sexplib0.Sexp.t);;[@@@end]end(** @canonical Base.Map.Finished_or_unfinished *)moduleFinished_or_unfinished=structtypet=|Finished|Unfinished[@@deriving_inlinecompare,enumerate,equal,sexp_of]letcompare=(Stdlib.compare:t->t->int)letall=([Finished;Unfinished]:tlist)letequal=(Stdlib.(=):t->t->bool)letsexp_of_t=(function|Finished->Sexplib0.Sexp.Atom"Finished"|Unfinished->Sexplib0.Sexp.Atom"Unfinished":t->Sexplib0.Sexp.t);;[@@@end]endmoduletypeAccessors_generic=sigtype('a,'b,'cmp)ttype('a,'b,'cmp)treetype'akeytype'cmpcmptype('a,'cmp,'z)access_options(** @inline *)includeDictionary_immutable.Accessorswithtype'keykey:='keykeyandtype('key,'data,'cmp)t:=('key,'data,'cmp)tandtype('fn,'key,_,'cmp)accessor:=('key,'cmp,'fn)access_optionsvalinvariants:('k,'cmp,('k,'v,'cmp)t->bool)access_optionsvalis_empty:(_,_,_)t->boolvallength:(_,_,_)t->intvaladd:('k,'cmp,('k,'v,'cmp)t->key:'kkey->data:'v->('k,'v,'cmp)tOr_duplicate.t)access_optionsvaladd_exn:('k,'cmp,('k,'v,'cmp)t->key:'kkey->data:'v->('k,'v,'cmp)t)access_optionsvalset:('k,'cmp,('k,'v,'cmp)t->key:'kkey->data:'v->('k,'v,'cmp)t)access_optionsvaladd_multi:('k,'cmp,('k,'vlist,'cmp)t->key:'kkey->data:'v->('k,'vlist,'cmp)t)access_optionsvalremove_multi:('k,'cmp,('k,'vlist,'cmp)t->'kkey->('k,'vlist,'cmp)t)access_optionsvalfind_multi:('k,'cmp,('k,'vlist,'cmp)t->'kkey->'vlist)access_optionsvalchange:('k,'cmp,('k,'v,'cmp)t->'kkey->f:('voption->'voption)->('k,'v,'cmp)t)access_optionsvalupdate:('k,'cmp,('k,'v,'cmp)t->'kkey->f:('voption->'v)->('k,'v,'cmp)t)access_optionsvalfind:('k,'cmp,('k,'v,'cmp)t->'kkey->'voption)access_optionsvalfind_exn:('k,'cmp,('k,'v,'cmp)t->'kkey->'v)access_optionsvalremove:('k,'cmp,('k,'v,'cmp)t->'kkey->('k,'v,'cmp)t)access_optionsvalmem:('k,'cmp,('k,_,'cmp)t->'kkey->bool)access_optionsvaliter_keys:('k,_,_)t->f:('kkey->unit)->unitvaliter:(_,'v,_)t->f:('v->unit)->unitvaliteri:('k,'v,_)t->f:(key:'kkey->data:'v->unit)->unitvaliteri_until:('k,'v,_)t->f:(key:'kkey->data:'v->Continue_or_stop.t)->Finished_or_unfinished.tvaliter2:('k,'cmp,('k,'v1,'cmp)t->('k,'v2,'cmp)t->f:(key:'kkey->data:('v1,'v2)Merge_element.t->unit)->unit)access_optionsvalmap:('k,'v1,'cmp)t->f:('v1->'v2)->('k,'v2,'cmp)tvalmapi:('k,'v1,'cmp)t->f:(key:'kkey->data:'v1->'v2)->('k,'v2,'cmp)tvalfold:('k,'v,_)t->init:'acc->f:(key:'kkey->data:'v->'acc->'acc)->'accvalfold_until:('k,'v,_)t->init:'acc->f:(key:'kkey->data:'v->'acc->('acc,'final)Container.Continue_or_stop.t)->finish:('acc->'final)->'finalvalfold_right:('k,'v,_)t->init:'acc->f:(key:'kkey->data:'v->'acc->'acc)->'accvalfold2:('k,'cmp,('k,'v1,'cmp)t->('k,'v2,'cmp)t->init:'acc->f:(key:'kkey->data:('v1,'v2)Merge_element.t->'acc->'acc)->'acc)access_optionsvalfilter_keys:('k,'v,'cmp)t->f:('kkey->bool)->('k,'v,'cmp)tvalfilter:('k,'v,'cmp)t->f:('v->bool)->('k,'v,'cmp)tvalfilteri:('k,'v,'cmp)t->f:(key:'kkey->data:'v->bool)->('k,'v,'cmp)tvalfilter_map:('k,'v1,'cmp)t->f:('v1->'v2option)->('k,'v2,'cmp)tvalfilter_mapi:('k,'v1,'cmp)t->f:(key:'kkey->data:'v1->'v2option)->('k,'v2,'cmp)tvalpartition_mapi:('k,'v1,'cmp)t->f:(key:'kkey->data:'v1->('v2,'v3)Either.t)->('k,'v2,'cmp)t*('k,'v3,'cmp)tvalpartition_map:('k,'v1,'cmp)t->f:('v1->('v2,'v3)Either.t)->('k,'v2,'cmp)t*('k,'v3,'cmp)tvalpartitioni_tf:('k,'v,'cmp)t->f:(key:'kkey->data:'v->bool)->('k,'v,'cmp)t*('k,'v,'cmp)tvalpartition_tf:('k,'v,'cmp)t->f:('v->bool)->('k,'v,'cmp)t*('k,'v,'cmp)tvalcombine_errors:('k,'cmp,('k,'vOr_error.t,'cmp)t->('k,'v,'cmp)tOr_error.t)access_optionsvalunzip:('k,'v1*'v2,'cmp)t->('k,'v1,'cmp)t*('k,'v2,'cmp)tvalcompare_direct:('k,'cmp,('v->'v->int)->('k,'v,'cmp)t->('k,'v,'cmp)t->int)access_optionsvalequal:('k,'cmp,('v->'v->bool)->('k,'v,'cmp)t->('k,'v,'cmp)t->bool)access_optionsvalkeys:('k,_,_)t->'kkeylistvaldata:(_,'v,_)t->'vlistvalto_alist:?key_order:[`Increasing|`Decreasing]->('k,'v,_)t->('kkey*'v)listvalmerge:('k,'cmp,('k,'v1,'cmp)t->('k,'v2,'cmp)t->f:(key:'kkey->('v1,'v2)Merge_element.t->'v3option)->('k,'v3,'cmp)t)access_optionsvalmerge_disjoint_exn:('k,'cmp,('k,'v,'cmp)t->('k,'v,'cmp)t->('k,'v,'cmp)t)access_optionsvalmerge_skewed:('k,'cmp,('k,'v,'cmp)t->('k,'v,'cmp)t->combine:(key:'kkey->'v->'v->'v)->('k,'v,'cmp)t)access_optionsvalsymmetric_diff:('k,'cmp,('k,'v,'cmp)t->('k,'v,'cmp)t->data_equal:('v->'v->bool)->('kkey,'v)Symmetric_diff_element.tSequence.t)access_optionsvalfold_symmetric_diff:('k,'cmp,('k,'v,'cmp)t->('k,'v,'cmp)t->data_equal:('v->'v->bool)->init:'acc->f:('acc->('kkey,'v)Symmetric_diff_element.t->'acc)->'acc)access_optionsvalmin_elt:('k,'v,_)t->('kkey*'v)optionvalmin_elt_exn:('k,'v,_)t->'kkey*'vvalmax_elt:('k,'v,_)t->('kkey*'v)optionvalmax_elt_exn:('k,'v,_)t->'kkey*'vvalfor_all:('k,'v,_)t->f:('v->bool)->boolvalfor_alli:('k,'v,_)t->f:(key:'kkey->data:'v->bool)->boolvalexists:('k,'v,_)t->f:('v->bool)->boolvalexistsi:('k,'v,_)t->f:(key:'kkey->data:'v->bool)->boolvalcount:('k,'v,_)t->f:('v->bool)->intvalcounti:('k,'v,_)t->f:(key:'kkey->data:'v->bool)->intvalsum:(moduleContainer.Summablewithtypet='a)->('k,'v,_)t->f:('v->'a)->'avalsumi:(moduleContainer.Summablewithtypet='a)->('k,'v,_)t->f:(key:'kkey->data:'v->'a)->'avalsplit:('k,'cmp,('k,'v,'cmp)t->'kkey->('k,'v,'cmp)t*('kkey*'v)option*('k,'v,'cmp)t)access_optionsvalsplit_le_gt:('k,'cmp,('k,'v,'cmp)t->'kkey->('k,'v,'cmp)t*('k,'v,'cmp)t)access_optionsvalsplit_lt_ge:('k,'cmp,('k,'v,'cmp)t->'kkey->('k,'v,'cmp)t*('k,'v,'cmp)t)access_optionsvalappend:('k,'cmp,lower_part:('k,'v,'cmp)t->upper_part:('k,'v,'cmp)t->[`Okof('k,'v,'cmp)t|`Overlapping_key_ranges])access_optionsvalsubrange:('k,'cmp,('k,'v,'cmp)t->lower_bound:'kkeyMaybe_bound.t->upper_bound:'kkeyMaybe_bound.t->('k,'v,'cmp)t)access_optionsvalfold_range_inclusive:('k,'cmp,('k,'v,'cmp)t->min:'kkey->max:'kkey->init:'acc->f:(key:'kkey->data:'v->'acc->'acc)->'acc)access_optionsvalrange_to_alist:('k,'cmp,('k,'v,'cmp)t->min:'kkey->max:'kkey->('kkey*'v)list)access_optionsvalclosest_key:('k,'cmp,('k,'v,'cmp)t->[`Greater_or_equal_to|`Greater_than|`Less_or_equal_to|`Less_than]->'kkey->('kkey*'v)option)access_optionsvalnth:('k,'v,'cmp)t->int->('kkey*'v)optionvalnth_exn:('k,'v,'cmp)t->int->'kkey*'vvalrank:('k,'cmp,('k,_,'cmp)t->'kkey->intoption)access_optionsvalto_tree:('k,'v,'cmp)t->('kkey,'v,'cmp)treevalto_sequence:('k,'cmp,?order:[`Increasing_key|`Decreasing_key]->?keys_greater_or_equal_to:'kkey->?keys_less_or_equal_to:'kkey->('k,'v,'cmp)t->('kkey*'v)Sequence.t)access_optionsvalbinary_search:('k,'cmp,('k,'v,'cmp)t->compare:(key:'kkey->data:'v->'key->int)->Binary_searchable.Which_target_by_key.t->'key->('kkey*'v)option)access_optionsvalbinary_search_segmented:('k,'cmp,('k,'v,'cmp)t->segment_of:(key:'kkey->data:'v->[`Left|`Right])->Binary_searchable.Which_target_by_segment.t->('kkey*'v)option)access_optionsvalbinary_search_subrange:('k,'cmp,('k,'v,'cmp)t->compare:(key:'kkey->data:'v->'bound->int)->lower_bound:'boundMaybe_bound.t->upper_bound:'boundMaybe_bound.t->('k,'v,'cmp)t)access_optionsmoduleMake_applicative_traversals(A:Applicative.Lazy_applicative):sigvalmapi:('k,'v1,'cmp)t->f:(key:'kkey->data:'v1->'v2A.t)->('k,'v2,'cmp)tA.tvalfilter_mapi:('k,'v1,'cmp)t->f:(key:'kkey->data:'v1->'v2optionA.t)->('k,'v2,'cmp)tA.tendendmoduletypeCreators_generic=sigtype('k,'v,'cmp)ttype('k,'v,'cmp)treetype'kkeytype('a,'cmp,'z)create_optionstype('a,'cmp,'z)access_optionstype'cmpcmp(** @inline *)includeDictionary_immutable.Creatorswithtype'keykey:='keykeyandtype('key,'data,'cmp)t:=('key,'data,'cmp)tandtype('fn,'key,_,'cmp)creator:=('key,'cmp,'fn)create_optionsvalempty:('k,'cmp,('k,_,'cmp)t)create_optionsvalsingleton:('k,'cmp,'kkey->'v->('k,'v,'cmp)t)create_optionsvalmap_keys:('k2,'cmp2,('k1,'v,'cmp1)t->f:('k1key->'k2key)->[`Okof('k2,'v,'cmp2)t|`Duplicate_keyof'k2key])create_optionsvalmap_keys_exn:('k2,'cmp2,('k1,'v,'cmp1)t->f:('k1key->'k2key)->('k2,'v,'cmp2)t)create_optionsvaltranspose_keys:('k1,'cmp1,('k2,'cmp2,('k1,('k2,'a,'cmp2)t,'cmp1)t->('k2,('k1,'a,'cmp1)t,'cmp2)t)create_options)access_optionsvalof_sorted_array:('k,'cmp,('kkey*'v)array->('k,'v,'cmp)tOr_error.t)create_optionsvalof_sorted_array_unchecked:('k,'cmp,('kkey*'v)array->('k,'v,'cmp)t)create_optionsvalof_increasing_iterator_unchecked:('k,'cmp,len:int->f:(int->'kkey*'v)->('k,'v,'cmp)t)create_optionsvalof_alist:('k,'cmp,('kkey*'v)list->[`Okof('k,'v,'cmp)t|`Duplicate_keyof'kkey])create_optionsvalof_alist_or_error:('k,'cmp,('kkey*'v)list->('k,'v,'cmp)tOr_error.t)create_optionsvalof_alist_exn:('k,'cmp,('kkey*'v)list->('k,'v,'cmp)t)create_optionsvalof_alist_multi:('k,'cmp,('kkey*'v)list->('k,'vlist,'cmp)t)create_optionsvalof_alist_fold:('k,'cmp,('kkey*'v1)list->init:'v2->f:('v2->'v1->'v2)->('k,'v2,'cmp)t)create_optionsvalof_alist_reduce:('k,'cmp,('kkey*'v)list->f:('v->'v->'v)->('k,'v,'cmp)t)create_optionsvalof_increasing_sequence:('k,'cmp,('kkey*'v)Sequence.t->('k,'v,'cmp)tOr_error.t)create_optionsvalof_sequence:('k,'cmp,('kkey*'v)Sequence.t->[`Okof('k,'v,'cmp)t|`Duplicate_keyof'kkey])create_optionsvalof_sequence_or_error:('k,'cmp,('kkey*'v)Sequence.t->('k,'v,'cmp)tOr_error.t)create_optionsvalof_sequence_exn:('k,'cmp,('kkey*'v)Sequence.t->('k,'v,'cmp)t)create_optionsvalof_sequence_multi:('k,'cmp,('kkey*'v)Sequence.t->('k,'vlist,'cmp)t)create_optionsvalof_sequence_fold:('k,'cmp,('kkey*'v1)Sequence.t->init:'v2->f:('v2->'v1->'v2)->('k,'v2,'cmp)t)create_optionsvalof_sequence_reduce:('k,'cmp,('kkey*'v)Sequence.t->f:('v->'v->'v)->('k,'v,'cmp)t)create_optionsvalof_list_with_key:('k,'cmp,'vlist->get_key:('v->'kkey)->[`Okof('k,'v,'cmp)t|`Duplicate_keyof'kkey])create_optionsvalof_list_with_key_or_error:('k,'cmp,'vlist->get_key:('v->'kkey)->('k,'v,'cmp)tOr_error.t)create_optionsvalof_list_with_key_exn:('k,'cmp,'vlist->get_key:('v->'kkey)->('k,'v,'cmp)t)create_optionsvalof_list_with_key_multi:('k,'cmp,'vlist->get_key:('v->'kkey)->('k,'vlist,'cmp)t)create_optionsvalof_list_with_key_fold:('k,'cmp,'vlist->get_key:('v->'kkey)->init:'acc->f:('acc->'v->'acc)->('k,'acc,'cmp)t)create_optionsvalof_list_with_key_reduce:('k,'cmp,'vlist->get_key:('v->'kkey)->f:('v->'v->'v)->('k,'v,'cmp)t)create_optionsvalof_iteri:('k,'cmp,iteri:(f:(key:'kkey->data:'v->unit)->unit)->[`Okof('k,'v,'cmp)t|`Duplicate_keyof'kkey])create_optionsvalof_iteri_exn:('k,'cmp,iteri:(f:(key:'kkey->data:'v->unit)->unit)->('k,'v,'cmp)t)create_optionsvalof_tree:('k,'cmp,('kkey,'v,'cmp)tree->('k,'v,'cmp)t)create_optionsendmoduletypeCreators_and_accessors_generic=sigtype('a,'b,'c)ttype('a,'b,'c)treetype'akeytype'acmptype('a,'b,'c)create_optionstype('a,'b,'c)access_optionsincludeCreators_genericwithtype('a,'b,'c)t:=('a,'b,'c)twithtype('a,'b,'c)tree:=('a,'b,'c)treewithtype'akey:='akeywithtype'acmp:='acmpwithtype('a,'b,'c)create_options:=('a,'b,'c)create_optionswithtype('a,'b,'c)access_options:=('a,'b,'c)access_optionsincludeAccessors_genericwithtype('a,'b,'c)t:=('a,'b,'c)twithtype('a,'b,'c)tree:=('a,'b,'c)treewithtype'akey:='akeywithtype'acmp:='acmpwithtype('a,'b,'c)access_options:=('a,'b,'c)access_optionsendmoduletypeS_poly=sigtype('a,'b)ttype('a,'b)treetypecomparator_witnessincludeCreators_and_accessors_genericwithtype('a,'b,'c)t:=('a,'b)twithtype('a,'b,'c)tree:=('a,'b)treewithtype'kkey:='kwithtype'ccmp:=comparator_witnesswithtype('a,'b,'c)create_options:=('a,'b,'c)Without_comparator.twithtype('a,'b,'c)access_options:=('a,'b,'c)Without_comparator.tendmoduletypeFor_deriving=sigtype('a,'b,'c)tmoduletypeSexp_of_m=sigtypet[@@deriving_inlinesexp_of]valsexp_of_t:t->Sexplib0.Sexp.t[@@@end]endmoduletypeM_of_sexp=sigtypet[@@deriving_inlineof_sexp]valt_of_sexp:Sexplib0.Sexp.t->t[@@@end]includeComparator.Swithtypet:=tendmoduletypeM_sexp_grammar=sigtypet[@@deriving_inlinesexp_grammar]valt_sexp_grammar:tSexplib0.Sexp_grammar.t[@@@end]endmoduletypeCompare_m=sigendmoduletypeEqual_m=sigendmoduletypeHash_fold_m=Hasher.Svalsexp_of_m__t:(moduleSexp_of_mwithtypet='k)->('v->Sexp.t)->('k,'v,'cmp)t->Sexp.tvalm__t_of_sexp:(moduleM_of_sexpwithtypet='kandtypecomparator_witness='cmp)->(Sexp.t->'v)->Sexp.t->('k,'v,'cmp)tvalm__t_sexp_grammar:(moduleM_sexp_grammarwithtypet='k)->'vSexplib0.Sexp_grammar.t->('k,'v,'cmp)tSexplib0.Sexp_grammar.tvalcompare_m__t:(moduleCompare_m)->('v->'v->int)->('k,'v,'cmp)t->('k,'v,'cmp)t->intvalequal_m__t:(moduleEqual_m)->('v->'v->bool)->('k,'v,'cmp)t->('k,'v,'cmp)t->boolvalhash_fold_m__t:(moduleHash_fold_mwithtypet='k)->(Hash.state->'v->Hash.state)->Hash.state->('k,'v,_)t->Hash.stateendmoduletypeMap=sig(** [Map] is a functional data structure (balanced binary tree) implementing finite maps
over a totally-ordered domain, called a "key". *)type(!'key,+!'value,!'cmp)tmoduleOr_duplicate=Or_duplicatemoduleContinue_or_stop=Continue_or_stopmoduleFinished_or_unfinished:sigtypet=Finished_or_unfinished.t=|Finished|Unfinished[@@deriving_inlinecompare,enumerate,equal,sexp_of]includePpx_compare_lib.Comparable.Swithtypet:=tincludePpx_enumerate_lib.Enumerable.Swithtypet:=tincludePpx_compare_lib.Equal.Swithtypet:=tvalsexp_of_t:t->Sexplib0.Sexp.t[@@@end](** Maps [Continue] to [Finished] and [Stop] to [Unfinished]. *)valof_continue_or_stop:Continue_or_stop.t->t(** Maps [Finished] to [Continue] and [Unfinished] to [Stop]. *)valto_continue_or_stop:t->Continue_or_stop.tendmoduleMerge_element:sigtype('left,'right)t=[`Leftof'left|`Rightof'right|`Bothof'left*'right][@@deriving_inlinecompare,equal,sexp_of]valcompare:('left->'left->int)->('right->'right->int)->('left,'right)t->('left,'right)t->intvalequal:('left->'left->bool)->('right->'right->bool)->('left,'right)t->('left,'right)t->boolvalsexp_of_t:('left->Sexplib0.Sexp.t)->('right->Sexplib0.Sexp.t)->('left,'right)t->Sexplib0.Sexp.t[@@@end]valleft:('left,_)t->'leftoptionvalright:(_,'right)t->'rightoptionvalleft_value:('left,_)t->default:'left->'leftvalright_value:(_,'right)t->default:'right->'rightvalvalues:('left,'right)t->left_default:'left->right_default:'right->'left*'rightend(** Test if the invariants of the internal AVL search tree hold. *)valinvariants:(_,_,_)t->bool(** Returns a first-class module that can be used to build other map/set/etc.
with the same notion of comparison. *)valcomparator_s:('a,_,'cmp)t->('a,'cmp)Comparator.Module.tvalcomparator:('a,_,'cmp)t->('a,'cmp)Comparator.t(** The empty map. *)valempty:('a,'cmp)Comparator.Module.t->('a,'b,'cmp)t(** A map with one (key, data) pair. *)valsingleton:('a,'cmp)Comparator.Module.t->'a->'b->('a,'b,'cmp)t(** Creates a map from an association list with unique keys. *)valof_alist:('a,'cmp)Comparator.Module.t->('a*'b)list->[`Okof('a,'b,'cmp)t|`Duplicate_keyof'a](** Creates a map from an association list with unique keys, returning an error if
duplicate ['a] keys are found. *)valof_alist_or_error:('a,'cmp)Comparator.Module.t->('a*'b)list->('a,'b,'cmp)tOr_error.t(** Creates a map from an association list with unique keys, raising an exception if
duplicate ['a] keys are found. *)valof_alist_exn:('a,'cmp)Comparator.Module.t->('a*'b)list->('a,'b,'cmp)t(** Creates a map from an association list with possibly repeated keys. The values in
the map for a given key appear in the same order as they did in the association
list. *)valof_alist_multi:('a,'cmp)Comparator.Module.t->('a*'b)list->('a,'blist,'cmp)t(** Combines an association list into a map, folding together bound values with common
keys. The accumulator is per-key.
Example:
{[
# (let map =
String.Map.of_alist_fold
[ "a", 1; "a", 10; "b", 2; "b", 20; "b", 200 ]
~init:Int.Set.empty
~f:Set.add
in
print_s [%sexp (map : Int.Set.t String.Map.t)]);;
((a (1 10)) (b (2 20 200)))
- : unit = ()
]}
*)valof_alist_fold:('a,'cmp)Comparator.Module.t->('a*'b)list->init:'c->f:('c->'b->'c)->('a,'c,'cmp)t(** Combines an association list into a map, reducing together bound values with common
keys. *)valof_alist_reduce:('a,'cmp)Comparator.Module.t->('a*'b)list->f:('b->'b->'b)->('a,'b,'cmp)t(** [of_iteri ~iteri] behaves like [of_alist], except that instead of taking a concrete
data structure, it takes an iteration function. For instance, to convert a string table
into a map: [of_iteri (module String) ~f:(Hashtbl.iteri table)]. It is faster than
adding the elements one by one. *)valof_iteri:('a,'cmp)Comparator.Module.t->iteri:(f:(key:'a->data:'b->unit)->unit)->[`Okof('a,'b,'cmp)t|`Duplicate_keyof'a](** Like [of_iteri] except that it raises an exception if duplicate ['a] keys are found. *)valof_iteri_exn:('a,'cmp)Comparator.Module.t->iteri:(f:(key:'a->data:'b->unit)->unit)->('a,'b,'cmp)t(** Creates a map from a sorted array of key-data pairs. The input array must be sorted
(either in ascending or descending order), as given by the relevant comparator, and
must not contain duplicate keys. If either of these conditions does not hold,
an error is returned. *)valof_sorted_array:('a,'cmp)Comparator.Module.t->('a*'b)array->('a,'b,'cmp)tOr_error.t(** Like [of_sorted_array] except that it returns a map with broken invariants when an
[Error] would have been returned. *)valof_sorted_array_unchecked:('a,'cmp)Comparator.Module.t->('a*'b)array->('a,'b,'cmp)t(** [of_increasing_iterator_unchecked c ~len ~f] behaves like [of_sorted_array_unchecked c
(Array.init len ~f)], with the additional restriction that a decreasing order is not
supported. The advantage is not requiring you to allocate an intermediate array. [f]
will be called with 0, 1, ... [len - 1], in order. *)valof_increasing_iterator_unchecked:('a,'cmp)Comparator.Module.t->len:int->f:(int->'a*'b)->('a,'b,'cmp)t(** [of_increasing_sequence c seq] behaves like [of_sorted_array c (Sequence.to_array
seq)], but does not allocate the intermediate array.
The sequence will be folded over once, and the additional time complexity is {e O(n)}.
*)valof_increasing_sequence:('k,'cmp)Comparator.Module.t->('k*'v)Sequence.t->('k,'v,'cmp)tOr_error.t(** Creates a map from an association sequence with unique keys.
[of_sequence c seq] behaves like [of_alist c (Sequence.to_list seq)] but
does not allocate the intermediate list.
If your sequence is increasing, use [of_increasing_sequence].
*)valof_sequence:('k,'cmp)Comparator.Module.t->('k*'v)Sequence.t->[`Okof('k,'v,'cmp)t|`Duplicate_keyof'k](** Creates a map from an association sequence with unique keys, returning an error if
duplicate ['a] keys are found.
[of_sequence_or_error c seq] behaves like [of_alist_or_error c (Sequence.to_list seq)]
but does not allocate the intermediate list.
*)valof_sequence_or_error:('a,'cmp)Comparator.Module.t->('a*'b)Sequence.t->('a,'b,'cmp)tOr_error.t(** Creates a map from an association sequence with unique keys, raising an exception if
duplicate ['a] keys are found.
[of_sequence_exn c seq] behaves like [of_alist_exn c (Sequence.to_list seq)] but
does not allocate the intermediate list.
*)valof_sequence_exn:('a,'cmp)Comparator.Module.t->('a*'b)Sequence.t->('a,'b,'cmp)t(** Creates a map from an association sequence with possibly repeated keys. The values in
the map for a given key appear in the same order as they did in the association
list.
[of_sequence_multi c seq] behaves like [of_alist_exn c (Sequence.to_list seq)] but
does not allocate the intermediate list.
*)valof_sequence_multi:('a,'cmp)Comparator.Module.t->('a*'b)Sequence.t->('a,'blist,'cmp)t(** Combines an association sequence into a map, folding together bound values with common
keys.
[of_sequence_fold c seq ~init ~f] behaves like [of_alist_fold c (Sequence.to_list seq) ~init ~f]
but does not allocate the intermediate list.
*)valof_sequence_fold:('a,'cmp)Comparator.Module.t->('a*'b)Sequence.t->init:'c->f:('c->'b->'c)->('a,'c,'cmp)t(** Combines an association sequence into a map, reducing together bound values with common
keys.
[of_sequence_reduce c seq ~f] behaves like [of_alist_reduce c (Sequence.to_list seq) ~f]
but does not allocate the intermediate list. *)valof_sequence_reduce:('a,'cmp)Comparator.Module.t->('a*'b)Sequence.t->f:('b->'b->'b)->('a,'b,'cmp)t(** Constructs a map from a list of values, where [get_key] extracts a key from a value.
*)valof_list_with_key:('k,'cmp)Comparator.Module.t->'vlist->get_key:('v->'k)->[`Okof('k,'v,'cmp)t|`Duplicate_keyof'k](** Like [of_list_with_key]; returns [Error] on duplicate key. *)valof_list_with_key_or_error:('k,'cmp)Comparator.Module.t->'vlist->get_key:('v->'k)->('k,'v,'cmp)tOr_error.t(** Like [of_list_with_key]; raises on duplicate key. *)valof_list_with_key_exn:('k,'cmp)Comparator.Module.t->'vlist->get_key:('v->'k)->('k,'v,'cmp)t(** Like [of_list_with_key]; produces lists of all values associated with each key. *)valof_list_with_key_multi:('k,'cmp)Comparator.Module.t->'vlist->get_key:('v->'k)->('k,'vlist,'cmp)t(** Like [of_list_with_key]; resolves duplicate keys the same way [of_alist_fold] does. *)valof_list_with_key_fold:('k,'cmp)Comparator.Module.t->'vlist->get_key:('v->'k)->init:'acc->f:('acc->'v->'acc)->('k,'acc,'cmp)t(** Like [of_list_with_key]; resolves duplicate keys the same way [of_alist_reduce] does. *)valof_list_with_key_reduce:('k,'cmp)Comparator.Module.t->'vlist->get_key:('v->'k)->f:('v->'v->'v)->('k,'v,'cmp)t(** Tests whether a map is empty. *)valis_empty:(_,_,_)t->bool(** [length map] returns the number of elements in [map]. O(1), but [Tree.length] is
O(n). *)vallength:(_,_,_)t->int(** Returns a new map with the specified new binding; if the key was already bound, its
previous binding disappears. *)valset:('k,'v,'cmp)t->key:'k->data:'v->('k,'v,'cmp)t(** [add t ~key ~data] adds a new entry to [t] mapping [key] to [data] and returns [`Ok]
with the new map, or if [key] is already present in [t], returns [`Duplicate]. *)valadd:('k,'v,'cmp)t->key:'k->data:'v->('k,'v,'cmp)tOr_duplicate.tvaladd_exn:('k,'v,'cmp)t->key:'k->data:'v->('k,'v,'cmp)t(** If [key] is not present then add a singleton list, otherwise, cons data onto the
head of the existing list. *)valadd_multi:('k,'vlist,'cmp)t->key:'k->data:'v->('k,'vlist,'cmp)t(** If the key is present, then remove its head element; if the result is empty, remove
the key. *)valremove_multi:('k,'vlist,'cmp)t->'k->('k,'vlist,'cmp)t(** Returns the value bound to the given key, or the empty list if there is none. *)valfind_multi:('k,'vlist,'cmp)t->'k->'vlist(** [change t key ~f] returns a new map [m] that is the same as [t] on all keys except
for [key], and whose value for [key] is defined by [f], i.e., [find m key = f (find
t key)]. *)valchange:('k,'v,'cmp)t->'k->f:('voption->'voption)->('k,'v,'cmp)t(** [update t key ~f] is [change t key ~f:(fun o -> Some (f o))]. *)valupdate:('k,'v,'cmp)t->'k->f:('voption->'v)->('k,'v,'cmp)t(** Returns [Some value] bound to the given key, or [None] if none exists. *)valfind:('k,'v,'cmp)t->'k->'voption(** Returns the value bound to the given key, raising [Stdlib.Not_found] or [Not_found_s]
if none exists. *)valfind_exn:('k,'v,'cmp)t->'k->'v(** Returns a new map with any binding for the key in question removed. *)valremove:('k,'v,'cmp)t->'k->('k,'v,'cmp)t(** [mem map key] tests whether [map] contains a binding for [key]. *)valmem:('k,_,'cmp)t->'k->boolvaliter_keys:('k,_,_)t->f:('k->unit)->unitvaliter:(_,'v,_)t->f:('v->unit)->unitvaliteri:('k,'v,_)t->f:(key:'k->data:'v->unit)->unit(** Iterates until the first time [f] returns [Stop]. If [f] returns [Stop], the final
result is [Unfinished]. Otherwise, the final result is [Finished]. *)valiteri_until:('k,'v,_)t->f:(key:'k->data:'v->Continue_or_stop.t)->Finished_or_unfinished.t(** Iterates two maps side by side. The complexity of this function is O(M + N). If two
inputs are [[(0, a); (1, a)]] and [[(1, b); (2, b)]], [f] will be called with [[(0,
`Left a); (1, `Both (a, b)); (2, `Right b)]]. *)valiter2:('k,'v1,'cmp)t->('k,'v2,'cmp)t->f:(key:'k->data:('v1,'v2)Merge_element.t->unit)->unit(** Returns a new map with bound values replaced by [f] applied to the bound values.*)valmap:('k,'v1,'cmp)t->f:('v1->'v2)->('k,'v2,'cmp)t(** Like [map], but the passed function takes both [key] and [data] as arguments. *)valmapi:('k,'v1,'cmp)t->f:(key:'k->data:'v1->'v2)->('k,'v2,'cmp)t(** Convert map with keys of type ['k2] to a map with keys of type ['k2] using [f]. *)valmap_keys:('k2,'cmp2)Comparator.Module.t->('k1,'v,'cmp1)t->f:('k1->'k2)->[`Okof('k2,'v,'cmp2)t|`Duplicate_keyof'k2](** Like [map_keys], but raises on duplicate key. *)valmap_keys_exn:('k2,'cmp2)Comparator.Module.t->('k1,'v,'cmp1)t->f:('k1->'k2)->('k2,'v,'cmp2)t(** Folds over keys and data in the map in increasing order of [key]. *)valfold:('k,'v,_)t->init:'acc->f:(key:'k->data:'v->'acc->'acc)->'acc(** Folds over keys and data in the map in increasing order of [key], until the first
time that [f] returns [Stop _]. If [f] returns [Stop final], this function returns
immediately with the value [final]. If [f] never returns [Stop _], and the final
call to [f] returns [Continue last], this function returns [finish last]. *)valfold_until:('k,'v,_)t->init:'acc->f:(key:'k->data:'v->'acc->('acc,'final)Container.Continue_or_stop.t)->finish:('acc->'final)->'final(** Folds over keys and data in the map in decreasing order of [key]. *)valfold_right:('k,'v,_)t->init:'acc->f:(key:'k->data:'v->'acc->'acc)->'acc(** Folds over two maps side by side, like [iter2]. *)valfold2:('k,'v1,'cmp)t->('k,'v2,'cmp)t->init:'acc->f:(key:'k->data:('v1,'v2)Merge_element.t->'acc->'acc)->'acc(** [filter], [filteri], [filter_keys], [filter_map], and [filter_mapi] run in O(n)
time.
[filter], [filteri], [filter_keys], [partition_tf] and [partitioni_tf] keep a lot
of sharing between their result and the original map. Dropping or keeping a run of
[k] consecutive elements costs [O(log(k))] extra memory. Keeping the entire map
costs no extra memory at all: [filter ~f:(fun _ -> true)] returns the original map.
*)valfilter_keys:('k,'v,'cmp)t->f:('k->bool)->('k,'v,'cmp)tvalfilter:('k,'v,'cmp)t->f:('v->bool)->('k,'v,'cmp)tvalfilteri:('k,'v,'cmp)t->f:(key:'k->data:'v->bool)->('k,'v,'cmp)t(** Returns a new map with bound values filtered by [f] applied to the bound values. *)valfilter_map:('k,'v1,'cmp)t->f:('v1->'v2option)->('k,'v2,'cmp)t(** Like [filter_map], but the passed function takes both [key] and [data] as
arguments. *)valfilter_mapi:('k,'v1,'cmp)t->f:(key:'k->data:'v1->'v2option)->('k,'v2,'cmp)t(** [partition_mapi t ~f] returns two new [t]s, with each key in [t] appearing in
exactly one of the resulting maps depending on its mapping in [f]. *)valpartition_mapi:('k,'v1,'cmp)t->f:(key:'k->data:'v1->('v2,'v3)Either.t)->('k,'v2,'cmp)t*('k,'v3,'cmp)t(** [partition_map t ~f = partition_mapi t ~f:(fun ~key:_ ~data -> f data)] *)valpartition_map:('k,'v1,'cmp)t->f:('v1->('v2,'v3)Either.t)->('k,'v2,'cmp)t*('k,'v3,'cmp)t(**
{[
partitioni_tf t ~f
=
partition_mapi t ~f:(fun ~key ~data ->
if f ~key ~data
then First data
else Second data)
]} *)valpartitioni_tf:('k,'v,'cmp)t->f:(key:'k->data:'v->bool)->('k,'v,'cmp)t*('k,'v,'cmp)t(** [partition_tf t ~f = partitioni_tf t ~f:(fun ~key:_ ~data -> f data)] *)valpartition_tf:('k,'v,'cmp)t->f:('v->bool)->('k,'v,'cmp)t*('k,'v,'cmp)t(** Produces [Ok] of a map including all keys if all data is [Ok], or an [Error]
including all errors otherwise. *)valcombine_errors:('k,'vOr_error.t,'cmp)t->('k,'v,'cmp)tOr_error.t(** Given a map of tuples, produces a tuple of maps. Equivalent to:
[map t ~f:fst, map t ~f:snd] *)valunzip:('k,'v1*'v2,'cmp)t->('k,'v1,'cmp)t*('k,'v2,'cmp)t(** Returns a total ordering between maps. The first argument is a total ordering used
to compare data associated with equal keys in the two maps. *)valcompare_direct:('v->'v->int)->('k,'v,'cmp)t->('k,'v,'cmp)t->int(** Hash function: a building block to use when hashing data structures containing maps in
them. [hash_fold_direct hash_fold_key] is compatible with [compare_direct] iff
[hash_fold_key] is compatible with [(comparator m).compare] of the map [m] being
hashed. *)valhash_fold_direct:'kHash.folder->'vHash.folder->('k,'v,'cmp)tHash.folder(** [equal cmp m1 m2] tests whether the maps [m1] and [m2] are equal, that is, contain
the same keys and associate each key with the same value. [cmp] is the equality
predicate used to compare the values associated with the keys. *)valequal:('v->'v->bool)->('k,'v,'cmp)t->('k,'v,'cmp)t->bool(** Returns a list of the keys in the given map. *)valkeys:('k,_,_)t->'klist(** Returns a list of the data in the given map. *)valdata:(_,'v,_)t->'vlist(** Creates an association list from the given map. *)valto_alist:?key_order:[`Increasing|`Decreasing](** default is [`Increasing] *)->('k,'v,_)t->('k*'v)list(** {2 Additional operations on maps} *)(** Merges two maps. The runtime is O(length(t1) + length(t2)). You shouldn't use this
function to merge a list of maps; consider using [merge_disjoin_exn] or
[merge_skewed] instead. *)valmerge:('k,'v1,'cmp)t->('k,'v2,'cmp)t->f:(key:'k->('v1,'v2)Merge_element.t->'v3option)->('k,'v3,'cmp)t(** Merges two dictionaries with the same type of data and disjoint sets of keys.
Raises if any keys overlap. *)valmerge_disjoint_exn:('k,'v,'cmp)t->('k,'v,'cmp)t->('k,'v,'cmp)t(** A special case of [merge], [merge_skewed t1 t2] is a map containing all the
bindings of [t1] and [t2]. Bindings that appear in both [t1] and [t2] are
combined into a single value using the [combine] function. In a call
[combine ~key v1 v2], the value [v1] comes from [t1] and [v2] from [t2].
The runtime of [merge_skewed] is [O(min(l1, l2) * log(max(l1, l2)))], where [l1] is
the length of [t1] and [l2] the length of [t2]. This is likely to be faster than
[merge] when one of the maps is a lot smaller, or when you merge a list of maps. *)valmerge_skewed:('k,'v,'cmp)t->('k,'v,'cmp)t->combine:(key:'k->'v->'v->'v)->('k,'v,'cmp)tmoduleSymmetric_diff_element:sigtype('k,'v)t='k*[`Leftof'v|`Rightof'v|`Unequalof'v*'v][@@deriving_inlinecompare,equal,sexp,sexp_grammar]includePpx_compare_lib.Comparable.S2withtype('k,'v)t:=('k,'v)tincludePpx_compare_lib.Equal.S2withtype('k,'v)t:=('k,'v)tincludeSexplib0.Sexpable.S2withtype('k,'v)t:=('k,'v)tvalt_sexp_grammar:'kSexplib0.Sexp_grammar.t->'vSexplib0.Sexp_grammar.t->('k,'v)tSexplib0.Sexp_grammar.t[@@@end]end(** [symmetric_diff t1 t2 ~data_equal] returns a list of changes between [t1] and [t2].
It is intended to be efficient in the case where [t1] and [t2] share a large amount
of structure. The keys in the output sequence will be in sorted order.
It is assumed that [data_equal] is at least as equating as physical equality: that
[phys_equal x y] implies [data_equal x y]. Otherwise, [symmetric_diff] may behave in
unexpected ways. For example, with [~data_equal:(fun _ _ -> false)] it is NOT
necessarily the case the resulting change sequence will contain an element
[(k, `Unequal _)] for every key [k] shared by both maps.
Warning: Float equality violates this property! [phys_equal Float.nan Float.nan] is
true, but [Float.(=) Float.nan Float.nan] is false. *)valsymmetric_diff:('k,'v,'cmp)t->('k,'v,'cmp)t->data_equal:('v->'v->bool)->('k,'v)Symmetric_diff_element.tSequence.t(** [fold_symmetric_diff t1 t2 ~data_equal] folds across an implicit sequence of changes
between [t1] and [t2], in sorted order by keys. Equivalent to
[Sequence.fold (symmetric_diff t1 t2 ~data_equal)], and more efficient. *)valfold_symmetric_diff:('k,'v,'cmp)t->('k,'v,'cmp)t->data_equal:('v->'v->bool)->init:'acc->f:('acc->('k,'v)Symmetric_diff_element.t->'acc)->'acc(** [min_elt map] returns [Some (key, data)] pair corresponding to the minimum key in
[map], or [None] if empty. *)valmin_elt:('k,'v,_)t->('k*'v)optionvalmin_elt_exn:('k,'v,_)t->'k*'v(** [max_elt map] returns [Some (key, data)] pair corresponding to the maximum key in
[map], or [None] if [map] is empty. *)valmax_elt:('k,'v,_)t->('k*'v)optionvalmax_elt_exn:('k,'v,_)t->'k*'v(** Swap the inner and outer keys of nested maps. If [transpose_keys m a = b], then
[find_exn (find_exn a i) j = find_exn (find_exn b j) i]. *)valtranspose_keys:('k2,'cmp2)Comparator.Module.t->('k1,('k2,'v,'cmp2)t,'cmp1)t->('k2,('k1,'v,'cmp1)t,'cmp2)t(** These functions have the same semantics as similar functions in [List]. *)valfor_all:('k,'v,_)t->f:('v->bool)->boolvalfor_alli:('k,'v,_)t->f:(key:'k->data:'v->bool)->boolvalexists:('k,'v,_)t->f:('v->bool)->boolvalexistsi:('k,'v,_)t->f:(key:'k->data:'v->bool)->boolvalcount:('k,'v,_)t->f:('v->bool)->intvalcounti:('k,'v,_)t->f:(key:'k->data:'v->bool)->intvalsum:(moduleContainer.Summablewithtypet='a)->('k,'v,_)t->f:('v->'a)->'avalsumi:(moduleContainer.Summablewithtypet='a)->('k,'v,_)t->f:(key:'k->data:'v->'a)->'a(** [split t key] returns a map of keys strictly less than [key], the mapping of [key] if
any, and a map of keys strictly greater than [key].
Runtime is O(m + log n), where n is the size of the input map and m is the size of
the smaller of the two output maps. The O(m) term is due to the need to calculate
the length of the output maps. *)valsplit:('k,'v,'cmp)t->'k->('k,'v,'cmp)t*('k*'v)option*('k,'v,'cmp)t(** [split_le_gt t key] returns a map of keys that are less or equal to [key] and a
map of keys strictly greater than [key].
Runtime is O(m + log n), where n is the size of the input map and m is the size of
the smaller of the two output maps. The O(m) term is due to the need to calculate
the length of the output maps. *)valsplit_le_gt:('k,'v,'cmp)t->'k->('k,'v,'cmp)t*('k,'v,'cmp)t(** [split_lt_ge t key] returns a map of keys strictly less than [key] and a map of
keys that are greater or equal to [key].
Runtime is O(m + log n), where n is the size of the input map and m is the size of
the smaller of the two output maps. The O(m) term is due to the need to calculate
the length of the output maps. *)valsplit_lt_ge:('k,'v,'cmp)t->'k->('k,'v,'cmp)t*('k,'v,'cmp)t(** [append ~lower_part ~upper_part] returns [`Ok map] where [map] contains all the
[(key, value)] pairs from the two input maps if all the keys from [lower_part] are
less than all the keys from [upper_part]. Otherwise it returns
[`Overlapping_key_ranges].
Runtime is O(log n) where n is the size of the larger input map. This can be
significantly faster than [Map.merge] or repeated [Map.add].
{[
assert (match Map.append ~lower_part ~upper_part with
| `Ok whole_map ->
Map.to_alist whole_map
= List.append (to_alist lower_part) (to_alist upper_part)
| `Overlapping_key_ranges -> true);
]} *)valappend:lower_part:('k,'v,'cmp)t->upper_part:('k,'v,'cmp)t->[`Okof('k,'v,'cmp)t|`Overlapping_key_ranges](** [subrange t ~lower_bound ~upper_bound] returns a map containing all the entries from
[t] whose keys lie inside the interval indicated by [~lower_bound] and
[~upper_bound]. If this interval is empty, an empty map is returned.
Runtime is O(m + log n), where n is the size of the input map and m is the size of
the output map. The O(m) term is due to the need to calculate the length of the
output map. *)valsubrange:('k,'v,'cmp)t->lower_bound:'kMaybe_bound.t->upper_bound:'kMaybe_bound.t->('k,'v,'cmp)t(** [fold_range_inclusive t ~min ~max ~init ~f] folds [f] (with initial value [~init])
over all keys (and their associated values) that are in the range [[min, max]]
(inclusive). *)valfold_range_inclusive:('k,'v,'cmp)t->min:'k->max:'k->init:'acc->f:(key:'k->data:'v->'acc->'acc)->'acc(** [range_to_alist t ~min ~max] returns an associative list of the elements whose keys
lie in [[min, max]] (inclusive), with the smallest key being at the head of the
list. *)valrange_to_alist:('k,'v,'cmp)t->min:'k->max:'k->('k*'v)list(** [closest_key t dir k] returns the [(key, value)] pair in [t] with [key] closest to
[k] that satisfies the given inequality bound.
For example, [closest_key t `Less_than k] would be the pair with the closest key to
[k] where [key < k].
[to_sequence] can be used to get the same results as [closest_key]. It is less
efficient for individual lookups but more efficient for finding many elements starting
at some value. *)valclosest_key:('k,'v,'cmp)t->[`Greater_or_equal_to|`Greater_than|`Less_or_equal_to|`Less_than]->'k->('k*'v)option(** [nth t n] finds the (key, value) pair of rank n (i.e., such that there are exactly n
keys strictly less than the found key), if one exists. O(log(length t) + n) time. *)valnth:('k,'v,_)t->int->('k*'v)optionvalnth_exn:('k,'v,_)t->int->'k*'v(** [rank t k] If [k] is in [t], returns the number of keys strictly less than [k] in
[t], and [None] otherwise. *)valrank:('k,'v,'cmp)t->'k->intoption(** [to_sequence ?order ?keys_greater_or_equal_to ?keys_less_or_equal_to t]
gives a sequence of key-value pairs between [keys_less_or_equal_to] and
[keys_greater_or_equal_to] inclusive, presented in [order]. If
[keys_greater_or_equal_to > keys_less_or_equal_to], the sequence is
empty.
When neither [keys_greater_or_equal_to] nor [keys_less_or_equal_to] are
provided, the cost is O(log n) up front and amortized O(1) to produce
each element. If either is provided (and is used by the order parameter
provided), then the the cost is O(n) up front, and amortized O(1) to
produce each element. *)valto_sequence:?order:[`Increasing_key(** default *)|`Decreasing_key]->?keys_greater_or_equal_to:'k->?keys_less_or_equal_to:'k->('k,'v,'cmp)t->('k*'v)Sequence.t(** [binary_search t ~compare which elt] returns the [(key, value)] pair in [t]
specified by [compare] and [which], if one exists.
[t] must be sorted in increasing order according to [compare], where [compare] and
[elt] divide [t] into three (possibly empty) segments:
{v
| < elt | = elt | > elt |
v}
[binary_search] returns an element on the boundary of segments as specified by
[which]. See the diagram below next to the [which] variants.
[binary_search] does not check that [compare] orders [t], and behavior is
unspecified if [compare] doesn't order [t]. Behavior is also unspecified if
[compare] mutates [t]. *)valbinary_search:('k,'v,'cmp)t->compare:(key:'k->data:'v->'key->int)->[`Last_strictly_less_than(** {v | < elt X | v} *)|`Last_less_than_or_equal_to(** {v | <= elt X | v} *)|`Last_equal_to(** {v | = elt X | v} *)|`First_equal_to(** {v | X = elt | v} *)|`First_greater_than_or_equal_to(** {v | X >= elt | v} *)|`First_strictly_greater_than(** {v | X > elt | v} *)]->'key->('k*'v)option(** [binary_search_segmented t ~segment_of which] takes a [segment_of] function that
divides [t] into two (possibly empty) segments:
{v
| segment_of elt = `Left | segment_of elt = `Right |
v}
[binary_search_segmented] returns the [(key, value)] pair on the boundary of the
segments as specified by [which]: [`Last_on_left] yields the last element of the
left segment, while [`First_on_right] yields the first element of the right segment.
It returns [None] if the segment is empty.
[binary_search_segmented] does not check that [segment_of] segments [t] as in the
diagram, and behavior is unspecified if [segment_of] doesn't segment [t]. Behavior
is also unspecified if [segment_of] mutates [t]. *)valbinary_search_segmented:('k,'v,'cmp)t->segment_of:(key:'k->data:'v->[`Left|`Right])->[`Last_on_left|`First_on_right]->('k*'v)option(** [binary_search_subrange] takes a [compare] function that divides [t] into three
(possibly empty) segments with respect to [lower_bound] and [upper_bound]:
{v
| Below_lower_bound | In_range | Above_upper_bound |
v}
and returns a map of the [In_range] segment.
Runtime is O(log m + n) where [m] is the length of the input map and [n] is the
length of the output. The linear term in [n] is to compute the length of the output.
Behavior is undefined if [compare] does not segment [t] as shown above, or if
[compare] mutates its inputs. *)valbinary_search_subrange:('k,'v,'cmp)t->compare:(key:'k->data:'v->'bound->int)->lower_bound:'boundMaybe_bound.t->upper_bound:'boundMaybe_bound.t->('k,'v,'cmp)t(** Creates traversals to reconstruct a map within an applicative. Uses
[Lazy_applicative] so that the map can be traversed within the applicative, rather
than needing to be traversed all at once, outside the applicative. *)moduleMake_applicative_traversals(A:Applicative.Lazy_applicative):sigvalmapi:('k,'v1,'cmp)t->f:(key:'k->data:'v1->'v2A.t)->('k,'v2,'cmp)tA.tvalfilter_mapi:('k,'v1,'cmp)t->f:(key:'k->data:'v1->'v2optionA.t)->('k,'v2,'cmp)tA.tend(** [M] is meant to be used in combination with OCaml applicative functor types:
{[
type string_to_int_map = int Map.M(String).t
]}
which stands for:
{[
type string_to_int_map = (String.t, int, String.comparator_witness) Map.t
]}
The point is that [int Map.M(String).t] supports deriving, whereas the second syntax
doesn't (because there is no such thing as, say, [String.sexp_of_comparator_witness]
-- instead you would want to pass the comparator directly).
In addition, when using [@@deriving], the requirements on the key module are only
those needed to satisfy what you are trying to derive on the map itself. Say you
write:
{[
type t = int Map.M(X).t [@@deriving hash]
]}
then this will be well typed exactly if [X] contains at least:
- a type [t] with no parameters
- a comparator witness
- a [hash_fold_t] function with the right type *)moduleM(K:sigtypettypecomparator_witnessend):sigtypenonrec'vt=(K.t,'v,K.comparator_witness)tendincludeFor_derivingwithtype('key,'value,'cmp)t:=('key,'value,'cmp)t(** [Using_comparator] is a similar interface as the toplevel of [Map], except the
functions take a [~comparator:('k, 'cmp) Comparator.t], whereas the functions at the
toplevel of [Map] take a [('k, 'cmp) comparator]. *)moduleUsing_comparator:sigtypenonrec('k,+'v,'cmp)t=('k,'v,'cmp)t[@@deriving_inlinesexp_of]valsexp_of_t:('k->Sexplib0.Sexp.t)->('v->Sexplib0.Sexp.t)->('cmp->Sexplib0.Sexp.t)->('k,'v,'cmp)t->Sexplib0.Sexp.t[@@@end]valt_of_sexp_direct:comparator:('k,'cmp)Comparator.t->(Sexp.t->'k)->(Sexp.t->'v)->Sexp.t->('k,'v,'cmp)tmoduleTree:sigtype(+'k,+'v,'cmp)t[@@deriving_inlinesexp_of]valsexp_of_t:('k->Sexplib0.Sexp.t)->('v->Sexplib0.Sexp.t)->('cmp->Sexplib0.Sexp.t)->('k,'v,'cmp)t->Sexplib0.Sexp.t[@@@end]valt_of_sexp_direct:comparator:('k,'cmp)Comparator.t->(Sexp.t->'k)->(Sexp.t->'v)->Sexp.t->('k,'v,'cmp)tincludeCreators_and_accessors_genericwithtype('a,'b,'c)t:=('a,'b,'c)twithtype('a,'b,'c)tree:=('a,'b,'c)twithtype'kkey:='kwithtype'ccmp:='cwithtype('a,'b,'c)create_options:=('a,'b,'c)With_comparator.twithtype('a,'b,'c)access_options:=('a,'b,'c)With_comparator.tvalempty_without_value_restriction:(_,_,_)t(** [Build_increasing] can be used to construct a map incrementally from a
sequence that is known to be increasing.
The total time complexity of constructing a map this way is O(n), which is more
efficient than using [Map.add] by a logarithmic factor.
This interface can be thought of as a dual of [to_sequence], but we don't have
an equally neat idiom for the duals of sequences ([of_sequence] is much less
general because it does not allow the sequence to be produced asynchronously). *)moduleBuild_increasing:sigtype('a,'b,'c)tree:=('a,'b,'c)ttype('k,'v,'w)tvalempty:('k,'v,'w)t(** Time complexity of [add_exn] is amortized constant-time (if [t] is used
linearly), with a worst-case O(log(n)) time. *)valadd_exn:('k,'v,'w)t->comparator:('k,'w)Comparator.t->key:'k->data:'v->('k,'v,'w)t(** Time complexity is O(log(n)). *)valto_tree:('k,'v,'w)t->('k,'v,'w)treeendendincludeCreators_and_accessors_genericwithtype('a,'b,'c)t:=('a,'b,'c)twithtype('a,'b,'c)tree:=('a,'b,'c)Tree.twithtype'kkey:='kwithtype'ccmp:='cwithtype('a,'b,'c)access_options:=('a,'b,'c)Without_comparator.twithtype('a,'b,'c)create_options:=('a,'b,'c)With_comparator.tvalcomparator:('a,_,'cmp)t->('a,'cmp)Comparator.tvalhash_fold_direct:'kHash.folder->'vHash.folder->('k,'v,'cmp)tHash.folder(** To get around the value restriction, apply the functor and include it. You
can see an example of this in the [Poly] submodule below. *)moduleEmpty_without_value_restriction(K:Comparator.S1):sigvalempty:('aK.t,'v,K.comparator_witness)tendend(** A polymorphic Map. *)modulePoly:S_polywithtype('key,+'value)t=('key,'value,Comparator.Poly.comparator_witness)tandtype('key,+'value)tree=('key,'value,Comparator.Poly.comparator_witness)Using_comparator.Tree.tandtypecomparator_witness=Comparator.Poly.comparator_witness(** Create a map from a tree using the given comparator. *)valof_tree:('k,'cmp)Comparator.Module.t->('k,'v,'cmp)Using_comparator.Tree.t->('k,'v,'cmp)t(** Extract a tree from a map. *)valto_tree:('k,'v,'cmp)t->('k,'v,'cmp)Using_comparator.Tree.t(** {2 Modules and module types for extending [Map]}
For use in extensions of Base, like [Core]. *)moduleWith_comparator=With_comparatormoduleWith_first_class_module=With_first_class_modulemoduleWithout_comparator=Without_comparatormoduletypeFor_deriving=For_derivingmoduletypeS_poly=S_polymoduletypeAccessors_generic=Accessors_genericmoduletypeCreators_and_accessors_generic=Creators_and_accessors_genericmoduletypeCreators_generic=Creators_genericend