concurrent-0

Safe HaskellNone
LanguageHaskell2010

Concurrent.Struct.Heap

Contents

Synopsis

Mutable API

newtype Heap k v s Source

Constructors

Heap (Ref (Node k v) s) 

newHeap :: MonadPrim s m => m (Heap k v s) Source

insert :: (MonadPrim s m, Ord k) => k -> v -> Heap k v s -> m (Node k v s) Source

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.

meld :: (MonadPrim s m, Ord k) => Heap k v s -> Heap k v s -> m () Source

delete :: (MonadPrim s m, Ord k) => Heap k v s -> Node k v s -> m () Source

setKey :: (MonadPrim s m, Ord k) => Heap k v s -> Node k v s -> k -> m () Source

Transient API

newtype Node k v s Source

Constructors

Node (Object s) 

Instances

Struct (Node k v) Source 
Eq (Node k v s) Source 

insertNode :: Ord k => k -> v -> TransientHeap k v s -> ST s (Node k v s, TransientHeap k v s) Source

insert k v h returns the pair (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

meldNode l r merges the contents of two transient min-heaps l 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)

key :: forall k v. Field (Node k v) k Source

value :: forall k v. Field (Node k v) v Source