| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Data.IntHeap
Synopsis
- newtype IntHeap = IntHeap {
- getIntHeap :: IntMap Int
- emptyIH :: IntHeap
- singletonIH :: Int -> IntHeap
- replicateIH :: Int -> Int -> IntHeap
- fromListIH :: [Int] -> IntHeap
- fromAscListIH :: [Int] -> IntHeap
- fromDistinctAscListIH :: [Int] -> IntHeap
- fromDescListIH :: [Int] -> IntHeap
- fromDistinctDescListIH :: [Int] -> IntHeap
- toListIH :: IntHeap -> [Int]
- toAscListIH :: IntHeap -> [Int]
- toDescListIH :: IntHeap -> [Int]
- insertIH :: Int -> IntHeap -> IntHeap
- deleteIH :: Int -> IntHeap -> IntHeap
- deleteAllIH :: Int -> IntHeap -> IntHeap
- memberIH :: Int -> IntHeap -> Bool
- notMemberIH :: Int -> IntHeap -> Bool
- countIH :: Int -> IntHeap -> Int
- lookupLTIH :: Int -> IntHeap -> Maybe Int
- lookupGTIH :: Int -> IntHeap -> Maybe Int
- lookupLEIH :: Int -> IntHeap -> Maybe Int
- lookupGEIH :: Int -> IntHeap -> Maybe Int
- nullIH :: IntHeap -> Bool
- sizeIH :: IntHeap -> Int
- findMinIH :: IntHeap -> Int
- findMaxIH :: IntHeap -> Int
- deleteMinIH :: IntHeap -> IntHeap
- deleteMaxIH :: IntHeap -> IntHeap
- deleteFindMinIH :: IntHeap -> (Int, IntHeap)
- deleteFindMaxIH :: IntHeap -> (Int, IntHeap)
- minViewIH :: IntHeap -> Maybe (Int, IntHeap)
- maxViewIH :: IntHeap -> Maybe (Int, IntHeap)
- splitIH :: Int -> IntHeap -> (IntHeap, IntHeap)
- splitLookupIH :: Int -> IntHeap -> (IntHeap, [Int], IntHeap)
Documentation
Constructors
| IntHeap | |
Fields
| |
singletonIH :: Int -> IntHeap Source #
replicateIH :: Int -> Int -> IntHeap Source #
O(1)
>>>replicateIH 3 1[1,1,1]>>>nullIH $ replicateIH 0 1True>>>nullIH $ replicateIH (-1) 1True
fromListIH :: [Int] -> IntHeap Source #
O(n min(n,W))
>>>fromListIH [0,1,2,1,0][0,0,1,1,2]
fromAscListIH :: [Int] -> IntHeap Source #
O(n)
>>>fromAscListIH [0,0,1,2][0,0,1,2]
fromDistinctAscListIH :: [Int] -> IntHeap Source #
O(n)
>>>fromDistinctAscListIH [0,1,2][0,1,2]
fromDescListIH :: [Int] -> IntHeap Source #
O(n)
>>>fromDescListIH [2,1,0,0][0,0,1,2]
fromDistinctDescListIH :: [Int] -> IntHeap Source #
O(n)
>>>fromDistinctDescListIH [2,1,0][0,1,2]
toAscListIH :: IntHeap -> [Int] Source #
O(n)
>>>toAscListIH (fromListIH [0,1,0,2])[0,0,1,2]
toDescListIH :: IntHeap -> [Int] Source #
O(n)
>>>toDescListIH (fromListIH [0,1,0,2])[2,1,0,0]
deleteIH :: Int -> IntHeap -> IntHeap Source #
O(min(n,W))
>>>deleteIH 0 (fromList [0, 0, 1, 2])[0,1,2]>>>deleteIH 3 (fromList [0, 0, 1, 2])[0,0,1,2]
deleteAllIH :: Int -> IntHeap -> IntHeap Source #
O(min(n,W))
>>>deleteAllIH 0 (fromList [0, 0, 1, 2])[1,2]>>>deleteAllIH 3 (fromList [0, 0, 1, 2])[0,0,1,2]
countIH :: Int -> IntHeap -> Int Source #
O(min(n, W))
>>>countIH 0 (fromList [0, 0, 1, 2])2>>>countIH 1 (fromList [0, 0, 1, 2])1>>>countIH (-1) (fromList [0, 0, 1, 2])0
lookupLTIH :: Int -> IntHeap -> Maybe Int Source #
O(log n)
>>>lookupLTIH 1 (fromList [0, 0, 1, 1, 2, 2])Just 0>>>lookupLTIH 0 (fromList [0, 0, 1, 1, 2, 2])Nothing
lookupGTIH :: Int -> IntHeap -> Maybe Int Source #
O(log n)
>>>lookupGTIH 1 (fromList [0, 0, 1, 1, 2, 2])Just 2>>>lookupGTIH 2 (fromList [0, 0, 1, 1, 2, 2])Nothing
lookupLEIH :: Int -> IntHeap -> Maybe Int Source #
O(log n)
>>>lookupLEIH 1 (fromList [0, 0, 1, 1, 2, 2])Just 1>>>lookupLEIH 0 (fromList [0, 0, 1, 1, 2, 2])Just 0>>>lookupLEIH (-1) (fromList [0, 0, 1, 1, 2, 2])Nothing
lookupGEIH :: Int -> IntHeap -> Maybe Int Source #
O(log n)
>>>lookupGEIH 1 (fromList [0, 0, 1, 1, 2, 2])Just 1>>>lookupGEIH 2 (fromList [0, 0, 1, 1, 2, 2])Just 2>>>lookupGEIH 3 (fromList [0, 0, 1, 1, 2, 2])Nothing
findMinIH :: IntHeap -> Int Source #
O(min(n,W))
>>>findMinIH (fromList [0, 0, 1, 2])0>>>findMinIH emptyIH*** Exception: findMin: empty map has no minimal element
findMaxIH :: IntHeap -> Int Source #
O(min(n,W))
>>>findMaxIH (fromList [0, 0, 1, 2])2>>>findMaxIH emptyIH*** Exception: findMax: empty map has no maximal element
deleteMinIH :: IntHeap -> IntHeap Source #
O(min(n,W))
>>>deleteMinIH (fromList [0, 0, 1, 2])[0,1,2]>>>deleteMinIH emptyIH*** Exception: updateMinWithKey Nil
deleteMaxIH :: IntHeap -> IntHeap Source #
O(min(n,W))
>>>deleteMaxIH (fromList [0, 1, 2, 2])[0,1,2]
>>>deleteMaxIH emptyIH*** Exception: updateMaxWithKey Nil
deleteFindMinIH :: IntHeap -> (Int, IntHeap) Source #
O(min(n,W))
>>>deleteFindMinIH (fromList [0, 0, 1, 2])(0,[0,1,2])>>>deleteFindMinIH emptyIHdeleteFindMin: empty map has no minimal element
deleteFindMaxIH :: IntHeap -> (Int, IntHeap) Source #
O(min(n,W))
>>>deleteFindMaxIH (fromList [0, 1, 2, 2])(2,[0,1,2])
>>>deleteFindMaxIH emptyIHdeleteFindMax: empty map has no maximal element
minViewIH :: IntHeap -> Maybe (Int, IntHeap) Source #
O(min(n,W))
>>>minViewIH (fromList [0, 0, 1, 2])Just (0,[0,1,2])
>>>minViewIH emptyIHNothing
maxViewIH :: IntHeap -> Maybe (Int, IntHeap) Source #
O(min(n,W))
>>>maxViewIH (fromList [0, 1, 2, 2])Just (2,[0,1,2])
>>>maxViewIH emptyIHNothing