{"id":32114304,"url":"https://github.com/fifth-postulate/priority-queue","last_synced_at":"2026-02-23T04:32:08.468Z","repository":{"id":57675088,"uuid":"258147424","full_name":"fifth-postulate/priority-queue","owner":"fifth-postulate","description":"A priority queue for Elm","archived":false,"fork":false,"pushed_at":"2020-04-23T12:18:27.000Z","size":36,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-08-08T20:39:19.736Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elm","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fifth-postulate.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-23T08:57:32.000Z","updated_at":"2022-03-05T17:37:15.000Z","dependencies_parsed_at":"2022-09-11T21:44:26.291Z","dependency_job_id":null,"html_url":"https://github.com/fifth-postulate/priority-queue","commit_stats":null,"previous_names":[],"tags_count":2,"template":null,"template_full_name":null,"purl":"pkg:github/fifth-postulate/priority-queue","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fifth-postulate%2Fpriority-queue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fifth-postulate%2Fpriority-queue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fifth-postulate%2Fpriority-queue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fifth-postulate%2Fpriority-queue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fifth-postulate","download_url":"https://codeload.github.com/fifth-postulate/priority-queue/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fifth-postulate%2Fpriority-queue/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29738079,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-23T02:24:00.660Z","status":"ssl_error","status_checked_at":"2026-02-23T02:22:56.087Z","response_time":90,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-20T15:16:50.099Z","updated_at":"2026-02-23T04:32:08.454Z","avatar_url":"https://github.com/fifth-postulate.png","language":"Elm","funding_links":[],"categories":[],"sub_categories":[],"readme":"# priority-queue[![Build Status](https://travis-ci.org/fifth-postulate/priority-queue.svg?branch=master)](https://travis-ci.org/fifth-postulate/priority-queue)\nA priority queue for Elm.\n\nA [*priority queue*][priority-queue] is an\n\n\u003e 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.\n\nThe implementation we provide here is based on Okasaki's *leftist heaps*. See [Purely Functional Data Structures][pfds] for more information.\n\n## Installation\nInstall `fifth-postulate/priority-queue` with the following command\n\n```sh\nelm install fifth-postulate/priority-queue\n```\n\n## Usage\nThe documentation for the `priority-queue` package can be found [online][documentation]. Below you can read how a `PriorityQueue` can be used.\n\nLet's say that for an artistic painting application you are maintaining a queue of rectangles to paint. The rectangles come in over a port and you want to paint larger, i.e. rectangles with a larger **area**, first. A priority queue helps in this scenario.\n\nTo create a queue you could use the `PriorityQueue.empty` function. It accepts a `Priority`, i.e. a function that assigns priority to elements. Note that lower values corresponds to higher priority. Think of the priority as the time you would be willing to wait before you would like to process the element.\n\nWe assume that there is a type alias `Rectangle` and a corresponding `area` function that returns the (integer) area of a rectangle.\n\n```elm\nqueue: PriorityQueue Rectangle\nqueue =\n    let\n        priority =\n            area \u003e\u003e negate\n    in\n    empty priority\n```\n\nHere area is composed with negate to ensure that larger areas have a higher priority.\n\nInserting a rectangle into a queue is done with the `insert` function. Given a `rectangle` and a `queue` the following code creates a new queue which contains the provided rectangle.\n\n```elm\nnextQueue = insert rectangle queue\n```\n\nNotice that it is not necessary to repeat the `Priority`. The queue already knows how to tell the priority for a rectangle.\n\n\nWhen it is time to draw a rectangle `head` could provide you with one.\n\n```elm\ncase head queue of\n    Nothing -\u003e\n        Cmd.none\n    \n    Just rectangle -\u003e\n        draw rectangle \n```\n\nThe `tail` function returns a priority queue of the remaining elements.\n\n[priority-queue]: https://en.wikipedia.org/wiki/Priority_queue\n[queue]: https://en.wikipedia.org/wiki/Queue_(abstract_data_type)\n[stack]: https://en.wikipedia.org/wiki/Stack_(abstract_data_type)\n[pfds]: https://www.cs.cmu.edu/~rwh/theses/okasaki.pdf\n[documentation]: https://package.elm-lang.org/packages/fifth-postulate/priority-queue/latest/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffifth-postulate%2Fpriority-queue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffifth-postulate%2Fpriority-queue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffifth-postulate%2Fpriority-queue/lists"}