1.0.0 • Published 4 years ago

@amirho/queue v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

Queue data structure

Queue data structure class using private features for private property

In computer science, a queue is a collection of entities that are maintained in a sequence and can be modified by the addition of entities at one end of the sequence and the removal of entities from the other end of the sequence. By convention, the end of the sequence at which elements are added is called the back, tail, or rear of the queue, and the end at which elements are removed is called the head or front of the queue, analogously to the words used when people line up to wait for goods or services.

The operation of adding an element to the rear of the queue is known as enqueue, and the operation of removing an element from the front is known as dequeue. Other operations may also be allowed, often including a peek or front operation that returns the value of the next element to be dequeued without dequeuing it.

Wikipedia

Table of Content

  1. Usage
  2. Methods
  3. Licence
  4. Author

Usage

installation

  npm i @amirho/queue

Methods

  1. enqueue() This method adds a new element at the back of the queue.
  2. dequeue() This method removes the first element from the queue (the item that is in the front of the queue). It also returns the removed element.
  3. size This property returns the size of the queue
  4. peek() This method returns the first element from the queue, the first one added, and the first one that will be removed from the queue. The queue is not modified (it does not remove the element; it only returns the element for information purposes - very similar to the peek method from the Stack class). This method also works as the front method, as it is known in other
  5. isEmpty() This method returns true if the queue is empty else returns false.
1.0.0

4 years ago