Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- newtype Multiset a = Multiset {
- getMultiset :: Map a Int
- emptyMS :: Multiset a
- singletonMS :: a -> Multiset a
- replicateMS :: Int -> a -> Multiset a
- fromListMS :: Ord a => [a] -> Multiset a
- fromAscListMS :: Eq a => [a] -> Multiset a
- fromDistinctAscListMS :: [a] -> Multiset a
- fromDescListMS :: Eq a => [a] -> Multiset a
- fromDistinctDescListMS :: [a] -> Multiset a
- toListMS :: Multiset a -> [a]
- toAscListMS :: Multiset a -> [a]
- toDescListMS :: Multiset a -> [a]
- insertMS :: Ord a => a -> Multiset a -> Multiset a
- deleteMS :: Ord a => a -> Multiset a -> Multiset a
- deleteAllMS :: Ord a => a -> Multiset a -> Multiset a
- memberMS :: Ord a => a -> Multiset a -> Bool
- notMemberMS :: Ord a => a -> Multiset a -> Bool
- countMS :: Ord a => a -> Multiset a -> Int
- lookupLTMS :: Ord a => a -> Multiset a -> Maybe a
- lookupGTMS :: Ord a => a -> Multiset a -> Maybe a
- lookupLEMS :: Ord a => a -> Multiset a -> Maybe a
- lookupGEMS :: Ord a => a -> Multiset a -> Maybe a
- nullMS :: Multiset a -> Bool
- sizeMS :: Multiset a -> Int
- distinctSizeMS :: Multiset a -> Int
- findMinMS :: Multiset a -> a
- findMaxMS :: Multiset a -> a
- deleteMinMS :: Multiset a -> Multiset a
- deleteMaxMS :: Multiset a -> Multiset a
- deleteFindMinMS :: forall a. Ord a => Multiset a -> (a, Multiset a)
- deleteFindMaxMS :: forall a. Ord a => Multiset a -> (a, Multiset a)
- minViewMS :: forall a. Ord a => Multiset a -> Maybe (a, Multiset a)
- maxViewMS :: forall a. Ord a => Multiset a -> Maybe (a, Multiset a)
- splitMS :: Ord a => a -> Multiset a -> (Multiset a, Multiset a)
- splitLookupMS :: Ord a => a -> Multiset a -> (Multiset a, [a], Multiset a)
Documentation
Multiset | |
|
singletonMS :: a -> Multiset a Source #
replicateMS :: Int -> a -> Multiset a Source #
O(1)
>>>
replicateMS 3 1
[1,1,1]>>>
nullMS $ replicateMS 0 1
True>>>
nullMS $ replicateMS (-1) 1
True
fromListMS :: Ord a => [a] -> Multiset a Source #
O(n log n)
>>>
fromListMS [0,1,2,1,0]
[0,0,1,1,2]
fromAscListMS :: Eq a => [a] -> Multiset a Source #
O(n)
>>>
fromAscListMS [0,0,1,2]
[0,0,1,2]
fromDistinctAscListMS :: [a] -> Multiset a Source #
O(n)
>>>
fromDistinctAscListMS [0,1,2]
[0,1,2]
fromDescListMS :: Eq a => [a] -> Multiset a Source #
O(n)
>>>
fromDescListMS [2,1,0,0]
[0,0,1,2]
fromDistinctDescListMS :: [a] -> Multiset a Source #
O(n)
>>>
fromDistinctDescListMS [2,1,0]
[0,1,2]
toAscListMS :: Multiset a -> [a] Source #
O(n)
>>>
toAscListMS (fromListMS [0,1,0,2])
[0,0,1,2]
toDescListMS :: Multiset a -> [a] Source #
O(n)
>>>
toDescListMS (fromListMS [0,1,0,2])
[2,1,0,0]
deleteMS :: Ord a => a -> Multiset a -> Multiset a Source #
O(log n)
>>>
deleteMS 0 (fromList [0, 0, 1, 2])
[0,1,2]>>>
deleteMS 3 (fromList [0, 0, 1, 2])
[0,0,1,2]
deleteAllMS :: Ord a => a -> Multiset a -> Multiset a Source #
O(log n)
>>>
deleteAllMS 0 (fromList [0, 0, 1, 2])
[1,2]>>>
deleteAllMS 3 (fromList [0, 0, 1, 2])
[0,0,1,2]
countMS :: Ord a => a -> Multiset a -> Int Source #
O(log n)
>>>
countMS 0 (fromList [0, 0, 1, 2])
2>>>
countMS 1 (fromList [0, 0, 1, 2])
1>>>
countMS (-1) (fromList [0, 0, 1, 2])
0
lookupLTMS :: Ord a => a -> Multiset a -> Maybe a Source #
O(log n)
>>>
lookupLTMS 1 (fromList [0, 0, 1, 1, 2, 2])
Just 0>>>
lookupLTMS 0 (fromList [0, 0, 1, 1, 2, 2])
Nothing
lookupGTMS :: Ord a => a -> Multiset a -> Maybe a Source #
O(log n)
>>>
lookupGTMS 1 (fromList [0, 0, 1, 1, 2, 2])
Just 2>>>
lookupGTMS 2 (fromList [0, 0, 1, 1, 2, 2])
Nothing
lookupLEMS :: Ord a => a -> Multiset a -> Maybe a Source #
O(log n)
>>>
lookupLEMS 1 (fromList [0, 0, 1, 1, 2, 2])
Just 1>>>
lookupLEMS 0 (fromList [0, 0, 1, 1, 2, 2])
Just 0>>>
lookupLEMS (-1) (fromList [0, 0, 1, 1, 2, 2])
Nothing
lookupGEMS :: Ord a => a -> Multiset a -> Maybe a Source #
O(log n)
>>>
lookupGEMS 1 (fromList [0, 0, 1, 1, 2, 2])
Just 1>>>
lookupGEMS 2 (fromList [0, 0, 1, 1, 2, 2])
Just 2>>>
lookupGEMS 3 (fromList [0, 0, 1, 1, 2, 2])
Nothing
distinctSizeMS :: Multiset a -> Int Source #
O(1) >>> distinctSizeMS (fromList [1,1,1,2,2,3]) 3
findMinMS :: Multiset a -> a Source #
O(log n)
>>>
findMinMS (fromList [0, 0, 1, 2])
0>>>
findMinMS emptyMS
*** Exception: Map.findMin: empty map has no minimal element
findMaxMS :: Multiset a -> a Source #
O(log n)
>>>
findMaxMS (fromList [0, 0, 1, 2])
2
>>>
findMaxMS emptyMS
*** Exception: Map.findMax: empty map has no maximal element
deleteMinMS :: Multiset a -> Multiset a Source #
O(log n)
>>>
deleteMinMS (fromList [0, 0, 1, 2])
[0,1,2]>>>
deleteMinMS emptyMS
[]
deleteMaxMS :: Multiset a -> Multiset a Source #
O(log n)
>>>
deleteMaxMS (fromList [0, 1, 2, 2])
[0,1,2]>>>
deleteMaxMS emptyMS
[]
deleteFindMinMS :: forall a. Ord a => Multiset a -> (a, Multiset a) Source #
O(log n)
>>>
deleteFindMinMS (fromList [0, 0, 1, 2])
(0,[0,1,2])>>>
deleteFindMinMS emptyMS
*** Exception: Map.deleteFindMin: can not return the minimal element of an empty map
deleteFindMaxMS :: forall a. Ord a => Multiset a -> (a, Multiset a) Source #
O(log n)
>>>
deleteFindMaxMS (fromList [0, 1, 2, 2])
(2,[0,1,2])
>>>
deleteFindMaxMS emptyMS
*** Exception: Map.deleteFindMax: can not return the maximal element of an empty map
minViewMS :: forall a. Ord a => Multiset a -> Maybe (a, Multiset a) Source #
O(log n)
>>>
minViewMS (fromList [0, 0, 1, 2])
Just (0,[0,1,2])
>>>
minViewMS emptyMS
Nothing
maxViewMS :: forall a. Ord a => Multiset a -> Maybe (a, Multiset a) Source #
O(log n)
>>>
maxViewMS (fromList [0, 1, 2, 2])
Just (2,[0,1,2])
>>>
maxViewMS emptyMS
Nothing