Safe Haskell | None |
---|---|
Language | Haskell2010 |
- newtype Heap k v s = Heap (Ref (Node k v) s)
- newHeap :: MonadPrim s m => m (Heap k v s)
- insert :: (MonadPrim s m, Ord k) => k -> v -> Heap k v s -> m (Node k v s)
- extractMin :: (MonadPrim s m, Ord k) => Heap k v s -> m (Node k v s)
- meld :: (MonadPrim s m, Ord k) => Heap k v s -> Heap k v s -> m ()
- delete :: (MonadPrim s m, Ord k) => Heap k v s -> Node k v s -> m ()
- setKey :: (MonadPrim s m, Ord k) => Heap k v s -> Node k v s -> k -> m ()
- newtype Node k v s = Node (Object s)
- insertNode :: Ord k => k -> v -> TransientHeap k v s -> ST s (Node k v s, TransientHeap k v s)
- extractMinNode :: Ord k => TransientHeap k v s -> ST s (Node k v s, TransientHeap k v s)
- meldNode :: Ord k => TransientHeap k v s -> TransientHeap k v s -> ST s (TransientHeap k v s)
- deleteNode :: Ord k => TransientHeap k v s -> Node k v s -> ST s (TransientHeap k v s)
- setKeyNode :: Ord k => TransientHeap k v s -> Node k v s -> k -> ST s (TransientHeap k v s)
- key :: forall k v. Field (Node k v) k
- value :: forall k v. Field (Node k v) v
Mutable API
extractMin :: (MonadPrim s m, Ord k) => Heap k v s -> m (Node k v s) Source
Returns Nil
if there isn't a minimum node.
Transient API
insertNode :: Ord k => k -> v -> TransientHeap k v s -> ST s (Node k v s, TransientHeap k v s) Source
returns the pair insert
k v h(n,h')
of the node for the inserted entry as well as the new heap
root.
extractMinNode :: Ord k => TransientHeap k v s -> ST s (Node k v s, TransientHeap k v s) Source
meldNode :: Ord k => TransientHeap k v s -> TransientHeap k v s -> ST s (TransientHeap k v s) Source
merges the contents of two transient min-heaps meldNode
l rl
and r
mutably. It destructively adds the contents of r
to l
and returns the modified l
.
deleteNode :: Ord k => TransientHeap k v s -> Node k v s -> ST s (TransientHeap k v s) Source
Remove a node from the heap it is in.
setKeyNode :: Ord k => TransientHeap k v s -> Node k v s -> k -> ST s (TransientHeap k v s) Source
Generalized decreaseKey
(allowed to increase key)