aivika-6.1: A multi-method simulation library
CopyrightCopyright (c) 2023 David Sorokin <davsor@mail.ru>
LicenseBSD3
MaintainerDavid Sorokin <david.sorokin@gmail.com>
Stabilityexperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010

Simulation.Aivika.PriorityQueue.EventQueue.Pure

Description

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

Documentation

data PriorityQueue a Source #

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

Instances

Instances details
Show a => Show (PriorityQueue a) Source # 
Instance details

Defined in Simulation.Aivika.PriorityQueue.EventQueue.Pure

type Priority = Int Source #

The priority value (greater is higher).

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.