(      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~(c) Twan van Laarhoven 2008 BSD-stylelibraries@haskell.org provisionalportableSafe*+D&The number of occurences of an elementA multiset of values a-. The same value can occur multiple times.O(n+m). See .O(1). Is this the empty multiset?O(n)). The number of elements in the multiset.O(1)2. The number of distinct elements in the multiset.O(log n)!. Is the element in the multiset?O(log n)%. Is the element not in the multiset?O(log n)7. The number of occurences of an element in a multiset. O(1). The empty mutli set. O(1). Create a singleton mutli set. O(log n)". Insert an element in a multiset. O(log n):. Insert an element in a multiset a given number of times.8Negative numbers remove occurences of the given element. O(log n)*. Delete a single element from a multiset.O(log n)<. Delete an element from a multiset a given number of times.5Negative numbers add occurences of the given element.O(log n)6. Delete all occurences of an element from a multiset.O(n+m)8. Is this a proper subset? (ie. a subset but not equal).O(n+m). Is this a subset? (s1 `isSubsetOf` s2) tells whether s1 is a subset of s2.O(log n)$. The minimal element of a multiset.O(log n)$. The maximal element of a multiset.O(log n). Delete the minimal element.O(log n). Delete the maximal element.O(log n)/. Delete all occurences of the minimal element.O(log n)/. Delete all occurences of the maximal element.O(log n)&. Delete and find the minimal element. 0deleteFindMin set = (findMin set, deleteMin set)O(log n)&. Delete and find the maximal element. 0deleteFindMax set = (findMax set, deleteMax set)O(log n)f. Retrieves the minimal element of the multiset, and the set with that element removed. Returns Nothing when passed an empty multiset.#Examples: >>> minView $ fromList [a, a, b, c ] Just (a,fromOccurList [(a,1),(b,1),(c,1)])O(log n)f. Retrieves the maximal element of the multiset, and the set with that element removed. Returns Nothing when passed an empty multiset.#Examples: >>> maxView $ fromList [a, a, b, c ] Just (c,fromOccurList [(a,2),(b,1)])#The union of a list of multisets: ( ==    ).O(n+m)E. The union of two multisets. The union adds the occurences together.&The implementation uses the efficient  hedge-union6 algorithm. Hedge-union is more efficient on (bigset  smallset).O(n+m). The union of two multisets. The number of occurences of each element in the union is the maximum of the number of occurences in the arguments (instead of the sum).&The implementation uses the efficient  hedge-union6 algorithm. Hedge-union is more efficient on (bigset  smallset).O(n+m)F. Difference of two multisets. The implementation uses an efficient hedge algorithm comparable with  hedge-union. O(n+m)i. The intersection of two multisets. Elements of the result come from the first multiset, so for example  import qualified Data.MultiSet as MS data AB = A | B deriving Show instance Ord AB where compare _ _ = EQ instance Eq AB where _ == _ = True main = print (MS.singleton A `MS.intersection` MS.singleton B, MS.singleton B `MS.intersection` MS.singleton A)prints (fromList [A],fromList [B]).!O(n)1. Filter all elements that satisfy the predicate."O(n). Partition the multiset into two multisets, one with all elements that satisfy the predicate and one with all elements that don't satisfy the predicate. See also >.# O(n*log n). # f s& is the multiset obtained by applying f to each element of s.$O(n). The $ f s == # f s, but works only when f is strictly monotonic.  The precondition is not checked. Semi-formally, we have: xand [x < y ==> f x < f y | x <- ls, y <- ls] ==> mapMonotonic f s == map f s where ls = toList s%O(n). Map and collect the  results.&O(n). Map and separate the  and  results.'O(n)E. Apply a function to each element, and take the union of the results(O(n)E. Apply a function to each element, and take the union of the results)O(n)). The monad join operation for multisets.*O(n)1. The monad bind operation, (>>=), for multisets.+O(t)?. Fold over the elements of a multiset in an unspecified order.O(t). Post-order fold.,O(n)=. Fold over the elements of a multiset with their occurences.-O(t). The elements of a multiset..O(n)Q. The distinct elements of a multiset, each element occurs only once in the list. %distinctElems = map fst . toOccurList/O(t)-. Convert the multiset to a list of elements.0O(t)8. Convert the multiset to an ascending list of elements.1 O(t*log t),. Create a multiset from a list of elements.2O(t);. Build a multiset from an ascending list in linear time. :The precondition (input list is ascending) is not checked.3O(n)P. Build a multiset from an ascending list of distinct elements in linear time. CThe precondition (input list is strictly ascending) is not checked.4O(n)<. Convert the multiset to a list of element/occurence pairs.5O(n)G. Convert the multiset to an ascending list of element/occurence pairs.6 O(n*log n);. Create a multiset from a list of element/occurence pairs.7O(n)V. Build a multiset from an ascending list of element/occurence pairs in linear time. :The precondition (input list is ascending) is not checked.8O(n)n. Build a multiset from an ascending list of elements/occurence pairs where each elements appears only once. CThe precondition (input list is strictly ascending) is not checked.9O(1). Convert a multiset to a ( from elements to number of occurrences.:O(n) . Convert a , from elements to occurrences to a multiset.;O(1) . Convert a ? from elements to occurrences to a multiset. Assumes that the ( contains only values larger than one. 3The precondition (all elements > 1) is not checked.<O(n). Convert a multiset to a , removing duplicates.=O(n) . Convert a  to a multiset.>O(log n). The expression (> x set ) is a pair  (set1,set2) where all elements in set1 are lower than x and all elements in set2 larger than x. x is not found in neither set1 nor set2.?O(log n) . Performs a >U but also returns the number of occurences of the pivot element in the original set.@O(n)\. Show the tree that implements the set. The tree is shown in a compressed, hanging format.AO(n). The expression (showTreeWith hang wide map.) shows the tree that implements the set. If hang is True, a hanging6 tree is shown otherwise a rotated tree is shown. If wide is !, an extra wide version is shown. Set> putStrLn $ showTreeWith True False $ fromDistinctAscList [1,1,2,3,4,5] (1*) 4 +--(1*) 2 | +--(2*) 1 | +--(1*) 3 +--(1*) 5 Set> putStrLn $ showTreeWith True True $ fromDistinctAscList [1,1,2,3,4,5] (1*) 4 | +--(1*) 2 | | | +--(2*) 1 | | | +--(1*) 3 | +--(1*) 5 Set> putStrLn $ showTreeWith False True $ fromDistinctAscList [1,1,2,3,4,5] +--(1*) 5 | (1*) 4 | | +--(1*) 3 | | +--(1*) 2 | +--(2*) 1BO(n)3. Test if the internal multiset structure is valid.O  !"#$%&'()*+,-./0123456789:;<=>?@ABC  !"#$%&'()*+,-./0123456789:;<=>?@ABC  !">?#$%&'(*)+,-./1023456789:;<=@ABM  !"#$%&'()*+,-./0123456789:;<=>?@AB (c) Twan van Laarhoven 2008 BSD-stylelibraries@haskell.org provisionalportableSafe*+EC&The number of occurences of an elementECA multiset of integers. The same value can occur multiple times.FO(n+m). See c.GO(1). Is this the empty multiset?HO(n)). The number of elements in the multiset.IO(1)2. The number of distinct elements in the multiset.J O(min(n,W))!. Is the element in the multiset?K O(min(n,W))%. Is the element not in the multiset?L O(min(n,W))7. The number of occurences of an element in a multiset.MO(1). The empty mutli set.NO(1). Create a singleton mutli set.O O(min(n,W))". Insert an element in a multiset.P O(min(n,W)):. Insert an element in a multiset a given number of times.8Negative numbers remove occurences of the given element.Q O(min(n,W))*. Delete a single element from a multiset.R O(min(n,W))<. Delete an element from a multiset a given number of times.5Negative numbers add occurences of the given element.S O(min(n,W))6. Delete all occurences of an element from a multiset.TO(n+m)8. Is this a proper subset? (ie. a subset but not equal).UO(n+m). Is this a subset? (s1 `isSubsetOf` s2) tells whether s1 is a subset of s2.O(log n). The minimal key of an IntMap.O(log n). The maximal key of an IntMap.VO(log n)$. The minimal element of a multiset.WO(log n)$. The maximal element of a multiset.XO(log n). Delete the minimal element.YO(log n). Delete the maximal element.ZO(log n)/. Delete all occurences of the minimal element.[O(log n)/. Delete all occurences of the maximal element.\O(log n)&. Delete and find the minimal element. 0deleteFindMin set = (findMin set, deleteMin set)]O(log n)&. Delete and find the maximal element. 0deleteFindMax set = (findMax set, deleteMax set)^O(log n)a. Retrieves the minimal element of the multiset, and the set stripped from that element Returns Nothing when passed an empty multiset.jExamples: >>> minView $ fromList [100, 100, 200, 300] Just (100,fromOccurList [(100,1),(200,1),(300,1)])_O(log n)Y. Retrieves the maximal element of the multiset, and the set stripped from that element fail/s (in the monad) when passed an empty multiset.bExamples: >>> maxView $ fromList [100, 100, 200, 300] Just (300,fromOccurList [(100,2),(200,1)])`#The union of a list of multisets: (` ==  a M).aO(n+m)E. The union of two multisets. The union adds the occurences together.&The implementation uses the efficient  hedge-union6 algorithm. Hedge-union is more efficient on (bigset a smallset).bO(n+m). The union of two multisets. The number of occurences of each element in the union is the maximum of the number of occurences in the arguments (instead of the sum).&The implementation uses the efficient  hedge-union6 algorithm. Hedge-union is more efficient on (bigset a smallset).cO(n+m)F. Difference of two multisets. The implementation uses an efficient hedge algorithm comparable with  hedge-union.dO(n+m)$. The intersection of two multisets.prints (fromList [A],fromList [B]).eO(n)1. Filter all elements that satisfy the predicate.fO(n). Partition the multiset into two multisets, one with all elements that satisfy the predicate and one with all elements that don't satisfy the predicate. See also .g O(n*log n). g f s& is the multiset obtained by applying f to each element of s.hO(n). The h f s == g f s, but works only when f is strictly monotonic.  The precondition is not checked. Semi-formally, we have: xand [x < y ==> f x < f y | x <- ls, y <- ls] ==> mapMonotonic f s == map f s where ls = toList siO(n). Map and collect the  results.jO(n). Map and separate the  and  results.kO(n)E. Apply a function to each element, and take the union of the resultslO(n)E. Apply a function to each element, and take the union of the resultsmO(n)). The monad join operation for multisets.nO(n)1. The monad bind operation, (>>=), for multisets.oO(t)?. Fold over the elements of a multiset in an unspecified order.O(t). Post-order fold.pO(n)=. Fold over the elements of a multiset with their occurences.qO(t). The elements of a multiset.rO(n)Q. The distinct elements of a multiset, each element occurs only once in the list. %distinctElems = map fst . toOccurListsO(t)-. Convert the multiset to a list of elements.tO(t)8. Convert the multiset to an ascending list of elements.u O(t*min(n,W)),. Create a multiset from a list of elements.vO(t);. Build a multiset from an ascending list in linear time. :The precondition (input list is ascending) is not checked.wO(n)P. Build a multiset from an ascending list of distinct elements in linear time. CThe precondition (input list is strictly ascending) is not checked.xO(n)<. Convert the multiset to a list of element/occurence pairs.yO(n)G. Convert the multiset to an ascending list of element/occurence pairs.z O(n*min(n,W));. Create a multiset from a list of element/occurence pairs.{O(n)V. Build a multiset from an ascending list of element/occurence pairs in linear time. :The precondition (input list is ascending) is not checked.|O(n)n. Build a multiset from an ascending list of elements/occurence pairs where each elements appears only once. CThe precondition (input list is strictly ascending) is not checked.}O(1). Convert a multiset to an ( from elements to number of occurrences.~O(n) . Convert an , from elements to occurrences to a multiset.O(1) . Convert an ? from elements to occurrences to a multiset. Assumes that the ( contains only values larger than one. 3The precondition (all elements > 1) is not checked.O(n). Convert a multiset to an , removing duplicates.O(n) . Convert an  to a multiset.O(log n). The expression ( x set ) is a pair  (set1,set2) where all elements in set1 are lower than x and all elements in set2 larger than x. x is not found in neither set1 nor set2.O(log n) . Performs a U but also returns the number of occurences of the pivot element in the original set.O(n)\. Show the tree that implements the set. The tree is shown in a compressed, hanging format.O(n). The expression (showTreeWith hang wide map.) shows the tree that implements the set. If hang is True, a hanging6 tree is shown otherwise a rotated tree is shown. If wide is !, an extra wide version is shown. Set> putStrLn $ showTreeWith True False $ fromDistinctAscList [1,1,2,3,4,5] (1*) 4 +--(1*) 2 | +--(2*) 1 | +--(1*) 3 +--(1*) 5 Set> putStrLn $ showTreeWith True True $ fromDistinctAscList [1,1,2,3,4,5] (1*) 4 | +--(1*) 2 | | | +--(2*) 1 | | | +--(1*) 3 | +--(1*) 5 Set> putStrLn $ showTreeWith False True $ fromDistinctAscList [1,1,2,3,4,5] +--(1*) 5 | (1*) 4 | | +--(1*) 3 | | +--(1*) 2 | +--(2*) 1PCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~CCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~CEDCFGHIJKLUTMNOPQRSa`bcdefghijklnmopVWXYZ[\]_^qrsutvwxyz{|}~NCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~F       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFG      !"#$%&'()*+,-./0123456789:;<=>?@ABCDHIJHKLHMNHMOPQRSQTUVWXYZ[\]^_`abcdePQfgYZ[\hijklmnmulti_0eJcFZi9IGPFWb7au2qqVz Data.MultiSetData.IntMultiSetOccurMultiSet\\nullsize distinctSizemember notMemberoccurempty singletoninsert insertManydelete deleteMany deleteAllisProperSubsetOf isSubsetOffindMinfindMax deleteMin deleteMax deleteMinAll deleteMaxAll deleteFindMin deleteFindMaxminViewmaxViewunionsunionmaxUnion difference intersectionfilter partitionmap mapMonotonicmapMaybe mapEither concatMap unionsMapjoinbindfold foldOccurelems distinctElemstoList toAscListfromList fromAscListfromDistinctAscList toOccurListtoAscOccurList fromOccurListfromAscOccurListfromDistinctAscOccurListtoMapfromMap fromOccurMaptoSetfromSetsplit splitOccurshowTree showTreeWithvalidKey IntMultiSetbase Data.FoldablefoldlGHC.BaseJust Data.EitherLeftRightfoldrconta_LKCPrTJwOTOLk4OU37YmeN Data.Map.BaseMap Data.Set.BaseSetghc-prim GHC.TypesTrueMSunMSdeleteN foldlStrict$fReadMultiSet$fShowMultiSet $fOrdMultiSet $fEqMultiSet$fDataMultiSet$fFoldableMultiSet$fMonoidMultiSetminKeymaxKeyData.IntMap.BaseIntMap$fReadIntMultiSet$fShowIntMultiSet$fOrdIntMultiSet$fEqIntMultiSet$fDataIntMultiSet$fMonoidIntMultiSet