Copyright | Copyright (c) 2023 David Sorokin <davsor@mail.ru> |
---|---|
License | BSD3 |
Maintainer | David Sorokin <david.sorokin@gmail.com> |
Stability | experimental |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Tested with: GHC 9.2.8
An immutable heap-based priority queue based on book Algorithms: A Functional Programming Approach by Fethi Rabhi and Guy Lapalme.
The queue allows specifying priorities along with keys.
Synopsis
- data PriorityQueue a
- type Priority = Int
- queueNull :: PriorityQueue a -> Bool
- queueCount :: PriorityQueue a -> Int
- emptyQueue :: PriorityQueue a
- enqueue :: PriorityQueue a -> Double -> Priority -> a -> PriorityQueue a
- dequeue :: PriorityQueue a -> PriorityQueue a
- queueFront :: PriorityQueue a -> (Double, Priority, a)
Documentation
data PriorityQueue a Source #
The PriorityQueue
type represents an immutable heap-based priority queue.
Instances
Show a => Show (PriorityQueue a) Source # | |
Defined in Simulation.Aivika.PriorityQueue.EventQueue.Pure showsPrec :: Int -> PriorityQueue a -> ShowS # show :: PriorityQueue a -> String # showList :: [PriorityQueue a] -> ShowS # |
queueNull :: PriorityQueue a -> Bool Source #
Test whether the priority queue is empty.
queueCount :: PriorityQueue a -> Int Source #
Return the number of elements in the priority queue.
emptyQueue :: PriorityQueue a Source #
An empty priority queue.
enqueue :: PriorityQueue a -> Double -> Priority -> a -> PriorityQueue a Source #
Enqueue a new element with the specified priority.
dequeue :: PriorityQueue a -> PriorityQueue a Source #
Dequeue the element with the minimal priority.
queueFront :: PriorityQueue a -> (Double, Priority, a) Source #
Return the element with the minimal priority.