Class Index | File Index

Classes


Class buckets.Queue

A queue is a First-In-First-Out (FIFO) data structure, the first element added to the queue will be the first one to be removed. This implementation uses a linked list as a container.
Defined in: <../buckets.js>.

Class Summary
Constructor Attributes Constructor Name and Description
 
Creates an empty queue.
Method Summary
Method Attributes Method Name and Description
 
add(elem)
Inserts the specified element into the end of this queue.
 
Removes all the elements from this queue.
 
contains(elem, equalsFunction)
Returns true if this queue contains the specified element.
 
Retrieves and removes the head of this queue.
 
enqueue(elem)
Inserts the specified element into the end of this queue.
 
forEach(callback)
Executes the provided function once for each element present in this queue in FIFO order.
 
Checks if this queue is empty.
 
peek()
Retrieves, but does not remove, the head of this queue.
 
size()
Returns the number of elements in this queue.
Class Detail
buckets.Queue()
Creates an empty queue.
Method Detail
{boolean} add(elem)
Inserts the specified element into the end of this queue. Equivalent to enqueue.
Parameters:
{Object} elem
The element to insert.
Returns:
{boolean} True if the element was inserted, or false if it is undefined.

clear()
Removes all the elements from this queue.

{boolean} contains(elem, equalsFunction)
Returns true if this queue contains the specified element.

If the elements inside this stack are not comparable with the === operator, a custom equals function should be provided to perform searches, the function must receive two arguments and return true if they are equal, false otherwise. Example:

var petsAreEqualByName = function(pet1, pet2) {
 return pet1.name === pet2.name;
}
Parameters:
{Object} elem
Element to search for.
{function(Object|Object):boolean=} equalsFunction
Optional function to check if two elements are equal.
Returns:
{boolean} True if this queue contains the specified element, false otherwise.

{*} dequeue()
Retrieves and removes the head of this queue.
Returns:
{*} The head of this queue, or undefined if this queue is empty.

{boolean} enqueue(elem)
Inserts the specified element into the end of this queue.
Parameters:
{Object} elem
The element to insert.
Returns:
{boolean} True if the element was inserted, or false if it is undefined.

forEach(callback)
Executes the provided function once for each element present in this queue in FIFO order.
Parameters:
{function(Object):*} callback
Function to execute, it is invoked with one argument: the element value, to break the iteration you can optionally return false inside the callback.

{boolean} isEmpty()
Checks if this queue is empty.
Returns:
{boolean} True if and only if this queue contains no items; false otherwise.

{*} peek()
Retrieves, but does not remove, the head of this queue.
Returns:
{*} The head of this queue, or undefined if this queue is empty.

{number} size()
Returns the number of elements in this queue.
Returns:
{number} The number of elements in this queue.

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Sep 17 2014 02:43:23 GMT-0500 (COT)