aivika-4.3.5: A multi-method simulation library

CopyrightCopyright (c) 2009-2015, David Sorokin <david.sorokin@gmail.com>
LicenseBSD3
MaintainerDavid Sorokin <david.sorokin@gmail.com>
Stabilityexperimental
Safe HaskellSafe
LanguageHaskell2010

Simulation.Aivika.PriorityQueue

Description

Tested with: GHC 7.10.1

An imperative heap-based priority queue.

Synopsis

Documentation

data PriorityQueue a Source

The PriorityQueue type represents an imperative heap-based priority queue.

queueNull :: PriorityQueue a -> IO Bool Source

Test whether the priority queue is empty.

queueCount :: PriorityQueue a -> IO Int Source

Return the number of elements in the priority queue.

newQueue :: IO (PriorityQueue a) Source

Create a new priority queue.

enqueue :: PriorityQueue a -> Double -> a -> IO () Source

Enqueue a new element with the specified priority.

dequeue :: PriorityQueue a -> IO () Source

Dequeue the element with the minimal priority.

queueFront :: PriorityQueue a -> IO (Double, a) Source

Return the element with the minimal priority.

queueDelete :: Eq a => PriorityQueue a -> a -> IO Bool Source

Remove the specified element from the queue and return a computation of the flag indicating whether the element was actually removed.

Note that unlike other functions it has complexity O(n).

queueDeleteBy :: PriorityQueue a -> (a -> Bool) -> IO (Maybe a) Source

Remove an element satisfying the predicate and return a computation of the element if found.

Note that unlike other functions it has complexity O(n).

queueContains :: Eq a => PriorityQueue a -> a -> IO Bool Source

Detect whether the specified element is contained in the queue.

Note that unlike other functions it has complexity O(n).

queueContainsBy :: PriorityQueue a -> (a -> Bool) -> IO (Maybe a) Source

Detect whether an element satisfying the predicate is contained in the queue.

Note that unlike other functions it has complexity O(n).

remove :: Eq a => PriorityQueue a -> a -> IO Bool Source

Deprecated: Use queueDelete instead.

Use queueDelete instead.

removeBy :: PriorityQueue a -> (a -> Bool) -> IO Bool Source

Deprecated: Use queueDeleteBy instead.

Use queueDeleteBy instead.