Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/turbomack/queue
Simple FIFO (first in, first out) Queue implementation in Elm
https://github.com/turbomack/queue
data-structures elm queue
Last synced: 20 days ago
JSON representation
Simple FIFO (first in, first out) Queue implementation in Elm
- Host: GitHub
- URL: https://github.com/turbomack/queue
- Owner: turboMaCk
- License: bsd-3-clause
- Created: 2017-05-03T18:35:50.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-09-07T12:08:55.000Z (over 4 years ago)
- Last Synced: 2024-10-16T08:21:55.988Z (2 months ago)
- Topics: data-structures, elm, queue
- Language: Elm
- Homepage: http://package.elm-lang.org/packages/turboMaCk/queue/latest
- Size: 19.5 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Queue
[![Build Status](https://travis-ci.org/turboMaCk/queue.svg?branch=master)](https://travis-ci.org/turboMaCk/queue)
Simple **FIFO** (first in, first out) queue data structure. First element added to the `Queue` is the first one to be removed.
If you're interested in double-ended queue implementation please see [folkertdev/elm-deque](http://package.elm-lang.org/packages/folkertdev/elm-deque/latest).**This package is highly experimental and might change a lot over time.**
Feedback and contributions to both code and documentation are very welcome.
# Performance
This implementation uses pair of `List`s
as described by Chris Okasaki in his [Purely Functional Data Structures](https://www.cs.cmu.edu/~rwh/theses/okasaki.pdf)
(page 15). One list is used for dequeuing elements, the other one is used for enqueuing new ones. Items in enqueuing `List` are
stored in reversed order so adding new elements is cheap (*O(1)*). When last element is taken out from dequeuing list
rebalancing of `Queue` happens. Rebalacing is done by reversing enqueuing list and storing it as new dequeuing list. This is costly operation
(*O(n)*). However it shouldn't happen too often due to access from just one side of a `Queue`. Most of the time both
`enqueue` and `dequeue` happens in *O(1)*. `front` is guaranteed to be *O(1)*.