Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rubico/monad/Queue #147

Open
richytong opened this issue Sep 12, 2020 · 0 comments
Open

rubico/monad/Queue #147

richytong opened this issue Sep 12, 2020 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@richytong
Copy link
Collaborator

Queue

the queue data structure

synopsis

new Queue(values Iterable|any) -> Queue {
  map: function,
  concat: function,
  chain: function,
  enqueue: function,
  dequeue: function,
  peek: function,
}

description

A Queue is a data structure that supports enqueue and dequeue operations in O(1) time as well as monadic operations that enable iteration, concatenation, and flattening. Items pushed into a queue are first in first out (FIFO).

const myQueue = new Queue([1, 2, 3])

console.log(myQueue) // Queue [3, 2, 1]

myQueue.enqueue(4)
myQueue.enqueue(5)
myQueue.enqueue(6)

console.log(myQueue) // Queue [6, 5, 4, 3, 2, 1]

console.log(myQueue.dequeue()) // 1
@richytong richytong added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Sep 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant