Home Reference Source
import {Queue} from 'rabbit-hole'
public class | source

Queue

A FIFO queue.

Elements are added to the end of the queue and removed from the front.

Based on: http://code.stephenmorley.org/javascript/queues/

Constructor Summary

Public Constructor
public

Constructs a new queue.

Member Summary

Public Members
public

A list of elements.

public get

Returns true if the queue is empty, and false otherwise.

public

The head of the queue.

public get

The current size of the queue.

Method Summary

Public Methods
public

add(element: Object)

Adds an element to the queue.

public

clear()

Resets this queue.

public

Clones this queue.

public

copy(queue: Queue): Queue

Copies the given queue.

public

Retrieves, but does not remove, the head of the queue.

public

Retrieves and removes the head of the queue.

Public Constructors

public constructor() source

Constructs a new queue.

Public Members

public elements: Array source

A list of elements.

public get empty: Boolean source

Returns true if the queue is empty, and false otherwise.

public head: Number source

The head of the queue.

public get size: Number source

The current size of the queue.

Public Methods

public add(element: Object) source

Adds an element to the queue.

Params:

NameTypeAttributeDescription
element Object

An arbitrary object.

public clear() source

Resets this queue.

public clone(): Queue source

Clones this queue.

Return:

Queue

Th cloned queue.

public copy(queue: Queue): Queue source

Copies the given queue.

Params:

NameTypeAttributeDescription
queue Queue

A queue.

Return:

Queue

This queue.

public peek(): Object source

Retrieves, but does not remove, the head of the queue.

Return:

Object

The head of the queue, or undefined if the queue is empty.

public poll(): Object source

Retrieves and removes the head of the queue.

Return:

Object

The head of the queue, or undefined if the queue is empty.