# FreeBSD Manual Pages

Map.S(3) OCamldoc Map.S(3)NAMEMap.S - Output signature of the functor Map.Make.Module typeModule type Map.SDocumentationModule typeS=sigendOutput signature of the functorMap.Make.typekeyThe type of the map keys.type+'atThe type of maps from typekeyto type'a.valempty:'atThe empty map.valis_empty:'at->boolTest whether a map is empty or not.valmem:key->'at->boolmemxmreturnstrueifmcontains a binding forx, andfalseother- wise.valadd:key->'a->'at->'ataddxymreturns a map containing the same bindings asm, plus a binding ofxtoy. Ifxwas already bound inmto a value that is physically equal toy,mis returned unchanged (the result of the function is then physically equal tom). Otherwise, the previous bind- ing ofxinmdisappears.Before4.03Physical equality was not ensured.valsingleton:key->'a->'atsingletonxyreturns the one-element map that contains a bindingyforx.Since3.12.0valremove:key->'at->'atremovexmreturns a map containing the same bindings asm, except forxwhich is unbound in the returned map. Ifxwas not inm,mis re- turned unchanged (the result of the function is then physically equal tom).Before4.03Physical equality was not ensured.valmerge:(key->'aoption->'boption->'coption)->'at->'bt->'ctmergefm1m2computes a map whose keys is a subset of keys ofm1and ofm2. The presence of each such binding, and the corresponding value, is determined with the functionf. In terms of thefind_optopera- tion, we havefind_optx(mergefm1m2)=f(find_optxm1)(find_optxm2)for any keyx, provided thatfNoneNone=None.Since3.12.0valunion:(key->'a->'a->'aoption)->'at->'at->'atunionfm1m2computes a map whose keys is the union of keys ofm1and ofm2. When the same binding is defined in both arguments, the func- tionfis used to combine them. This is a special case ofmerge:unionfm1m2is equivalent tomergef'm1m2, where -f'NoneNone=None-f'(Somev)None=Somev-f'None(Somev)=Somev-f'(Somev1)(Somev2)=fv1v2Since4.03.0valcompare:('a->'a->int)->'at->'at->intTotal ordering between maps. The first argument is a total ordering used to compare data associated with equal keys in the two maps.valequal:('a->'a->bool)->'at->'at->boolequalcmpm1m2tests whether the mapsm1andm2are equal, that is, contain equal keys and associate them with equal data.cmpis the equality predicate used to compare the data associated with the keys.valiter:(key->'a->unit)->'at->unititerfmappliesfto all bindings in mapm.freceives the key as first argument, and the associated value as second argument. The bind- ings are passed tofin increasing order with respect to the ordering over the type of the keys.valfold:(key->'a->'b->'b)->'at->'b->'bfoldfmacomputes(fkNdN...(fk1d1a)...), wherek1...kNare the keys of all bindings inm(in increasing order), andd1...dNare the associated data.valfor_all:(key->'a->bool)->'at->boolfor_allpmchecks if all the bindings of the map satisfy the predicatep.Since3.12.0valexists:(key->'a->bool)->'at->boolexistspmchecks if at least one binding of the map satisfies the predicatep.Since3.12.0valfilter:(key->'a->bool)->'at->'atfilterpmreturns the map with all the bindings inmthat satisfy predicatep. Ifpsatisfies every binding inm,mis returned un- changed (the result of the function is then physically equal tom)Before4.03Physical equality was not ensured.Since3.12.0valpartition:(key->'a->bool)->'at->'at*'atpartitionpmreturns a pair of maps(m1,m2), wherem1contains all the bindings ofsthat satisfy the predicatep, andm2is the map with all the bindings ofsthat do not satisfyp.Since3.12.0valcardinal:'at->intReturn the number of bindings of a map.Since3.12.0valbindings:'at->(key*'a)listReturn the list of all bindings of the given map. The returned list is sorted in increasing order with respect to the orderingOrd.compare, whereOrdis the argument given toMap.Make.Since3.12.0valmin_binding:'at->key*'aReturn the smallest binding of the given map (with respect to theOrd.compareordering), or raiseNot_foundif the map is empty.Since3.12.0valmin_binding_opt:'at->(key*'a)optionReturn the smallest binding of the given map (with respect to theOrd.compareordering), orNoneif the map is empty.Since4.05valmax_binding:'at->key*'aSame asMap.S.min_binding, but returns the largest binding of the given map.Since3.12.0valmax_binding_opt:'at->(key*'a)optionSame asMap.S.min_binding_opt, but returns the largest binding of the given map.Since4.05valchoose:'at->key*'aReturn one binding of the given map, or raiseNot_foundif the map is empty. Which binding is chosen is unspecified, but equal bindings will be chosen for equal maps.Since3.12.0valchoose_opt:'at->(key*'a)optionReturn one binding of the given map, orNoneif the map is empty. Which binding is chosen is unspecified, but equal bindings will be chosen for equal maps.Since4.05valsplit:key->'at->'at*'aoption*'atsplitxmreturns a triple(l,data,r), wherelis the map with all the bindings ofmwhose key is strictly less thanx;ris the map with all the bindings ofmwhose key is strictly greater thanx;dataisNoneifmcontains no binding forx, orSomevifmbindsvtox.Since3.12.0valfind:key->'at->'afindxmreturns the current binding ofxinm, or raisesNot_foundif no such binding exists.valfind_opt:key->'at->'aoptionfind_optxmreturnsSomevif the current binding ofxinmisv, orNoneif no such binding exists.Since4.05valfind_first:(key->bool)->'at->key*'afind_firstfm, wherefis a monotonically increasing function, re- turns the binding ofmwith the lowest keyksuch thatfk, or raisesNot_foundif no such key exists. For example,find_first(funk->Ord.comparekx>=0)mwill return the first bindingk,vofmwhereOrd.comparekx>=0(intuitively:k>=x), or raiseNot_foundifxis greater than any element ofm.Since4.05valfind_first_opt:(key->bool)->'at->(key*'a)optionfind_first_optfm, wherefis a monotonically increasing function, returns an option containing the binding ofmwith the lowest keyksuch thatfk, orNoneif no such key exists.Since4.05valfind_last:(key->bool)->'at->key*'afind_lastfm, wherefis a monotonically decreasing function, returns the binding ofmwith the highest keyksuch thatfk, or raisesNot_foundif no such key exists.Since4.05valfind_last_opt:(key->bool)->'at->(key*'a)optionfind_last_optfm, wherefis a monotonically decreasing function, re- turns an option containing the binding ofmwith the highest keyksuch thatfk, orNoneif no such key exists.Since4.05valmap:('a->'b)->'at->'btmapfmreturns a map with same domain asm, where the associated valueaof all bindings ofmhas been replaced by the result of the ap- plication offtoa. The bindings are passed tofin increasing order with respect to the ordering over the type of the keys.valmapi:(key->'a->'b)->'at->'btSame asMap.S.map, but the function receives as arguments both the key and the associated value for each binding of the map. 2020-08-11 source: Map.S(3)

NAME | Module type | Documentation

Want to link to this manual page? Use this URL:

<https://www.freebsd.org/cgi/man.cgi?query=Map.S&sektion=3o&manpath=FreeBSD+12.1-RELEASE+and+Ports>