HAN-ASD-DT/priority-queue/1.0.0

NOTE: the latest version is 2.1.1

Rerouted (fork, verified). The original repository is gone. This copy comes from a fork that still has the tag. The Lamdera package server serves a copy recovered from https://github.com/fifth-postulate/priority-queue (a fork).

What we checked: Rebuilt with git archive from commit dd9dafe97f8f of https://github.com/fifth-postulate/priority-queue (a fork) (zip prefix HAN-ASD-DT-priority-queue-dd9dafe/, America/Los_Angeles times): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 db4090894fc9eb435b28e5df3f02ca1135a5a5a3.

The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.

Details · package.elm-lang.org's zip: https://github.com/HAN-ASD-DT/priority-queue/zipball/1.0.0/

PriorityQueue

A priority queue for Elm.

A priority queue is an

abstract data type which is like a regular queue or stack data structure, but where additionally each element has a "priority" associated with it. In a priority queue, an element with high priority is served before an element with low priority.

The implementation we provide here is based on Okasaki's leftist heaps. See Purely Functional Data Structures for more information.

Priority

Throughout this package priority will mean a function that assigns a integer value to an element. Lower values indicate higher priority and vice versa.

Types

type alias PriorityQueue a =
PriorityQueue a

The abstract datatype of this package.

type alias Priority a =
Priority a

A function that assigns a priority to elements.

Higher values correspond to higher priority.

Building

empty : Priority a -> PriorityQueue a

Create an empty PriorityQueue.

insert : a -> PriorityQueue a -> PriorityQueue a

Insert an element into the PriorityQueue

fromList : (a -> Int) -> List a -> PriorityQueue a

Creates a PriorityQueue from a given list of elements.

Must be given a priority function, i.e. a function that assigns the priority to elements.

Query

tail : PriorityQueue a -> PriorityQueue a

Return the PriorityQueue that remains when the head is removed.

Conversion

toList : PriorityQueue a -> List a

Returns all the elements in a PriorityQueue as a List.

The order will be determined by the priority, higher priority elements before lower priority elements.