Class Index | File Index

Classes


Class Queue


Defined in: DataStructures.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Queue(args)
Class for managing a queue.
Field Summary
Field Attributes Field Name and Description
 
The list of the items in the queue.
Method Summary
Method Attributes Method Name and Description
 
allIndexesOf(item, callback)
Returns all the position in which the item has been found in the queue.
 
Removes all the items stored in the queue.
 
Clones the queue into a new queue.
 
Clones the queue into a new queue without cloning duplicated items.
 
contains(item, callback)
Checks if the queue contains an item that satisfy the condition represented by the callback function.
 
Removes the item at the head of the queue.
 
enqueue(item)
Adds the item at the tail of the queue.
 
execute(callback)
Executes the callback function for each item of the queue.
 
filter(callback)
Returns the items that satisfy the condition determined by the callback.
 
getItem(index)
Returns the item at the position index.
 
Returns the iterator relative to the aggregate.
 
Returns the length of the queue.
 
indexOf(item, callback)
Returns the first position of the item in the queue.
 
Checks if the queue is empty.
 
lastIndexOf(item, callback)
Returns the last position of the item in the queue.
 
multiDequeue(times)
Removes the items at the head of the queue.
 
multiEnqueue(items)
Adds the items at the tail of the queue.
 
peek()
Returns the first item in the queue.
 
remove(index, length)
Removes the first length items from the position index.
Class Detail
Queue(args)
Class for managing a queue.
Parameters:
{...*} args Optional
The items for initializing the queue.
Field Detail
items
The list of the items in the queue.
Method Detail
{Array} allIndexesOf(item, callback)
Returns all the position in which the item has been found in the queue.
Parameters:
item
{*} The item to search.
callback Optional, Default: function(item){return(it===item);}
The condition to satisfy. The callback must accept the current item to check.
Returns:
{Array} The positions in which the item has been found.

{void} clear()
Removes all the items stored in the queue.
Returns:
{void}

{Queue} clone()
Clones the queue into a new queue.
Returns:
{Queue} The queue cloned from this queue.

{Queue} cloneDistinct()
Clones the queue into a new queue without cloning duplicated items.
Returns:
{Queue} The queue cloned from this queue.

{boolean} contains(item, callback)
Checks if the queue contains an item that satisfy the condition represented by the callback function.
Parameters:
item
{*} The item to find.
callback Optional, Default: function(item){return(it===item);}
The condition to satisfy. The callback must accept the current item to check.
Returns:
{boolean} True if the queue contains the item that satisfy the condition, false otherwise.

{*} dequeue()
Removes the item at the head of the queue.
Returns:
{*} The item at the head of the queue. It's undefined if the queue is empty.

{void} enqueue(item)
Adds the item at the tail of the queue.
Parameters:
item
{*} The item to add.
Returns:
{void}

{void} execute(callback)
Executes the callback function for each item of the queue. This method modifies the queue so if you don't need to modify it you must return the same item of the array.
Parameters:
callback
{function} The function to execute for each item. The function must accept the current item on which execute the function.
Returns:
{void}

{Array<*>} filter(callback)
Returns the items that satisfy the condition determined by the callback.
Parameters:
callback
{function} The function that implements the condition.
Returns:
{Array<*>} The array that contains the items that satisfy the condition.

{*} getItem(index)
Returns the item at the position index.
Parameters:
index
{number} The position of the item.
Returns:
{*} The item at the position. It's undefined if index isn't in the queue bounds.

{Iterator} getIterator()
Returns the iterator relative to the aggregate.
Returns:
{Iterator} The iterator.

{number} getLength()
Returns the length of the queue.
Returns:
{number} The length of the queue.

{number} indexOf(item, callback)
Returns the first position of the item in the queue.
Parameters:
item
{*} The item to search.
callback Optional, Default: function(item){return(it===item);}
The condition to satisfy. The callback must accept the current item to check.
Returns:
{number} The first position of the item.

{boolean} isEmpty()
Checks if the queue is empty.
Returns:
{boolean} True if the queue is empty, false otherwise.

{number} lastIndexOf(item, callback)
Returns the last position of the item in the queue.
Parameters:
item
{*} The item to search.
callback Optional, Default: function(item){return(it===item);}
The condition to satisfy. The callback must accept the current item to check.
Returns:
{number} The last position of the item.

{Array<*>} multiDequeue(times)
Removes the items at the head of the queue.
Parameters:
times
{number} The number of times to repeat the dequeue method.
Returns:
{Array<*>} The items at the head of the queue.

{void} multiEnqueue(items)
Adds the items at the tail of the queue.
Parameters:
items
{Array<*>} The items to add.
Returns:
{void}

{*} peek()
Returns the first item in the queue. The item is not removed.
Returns:
{*} The first item. It's undefined if the queue is empty.

{void} remove(index, length)
Removes the first length items from the position index.
Parameters:
index
{number} The position where to start to remove the items.
length Optional, Default: 1
{number} The number of items to remove.
Returns:
{void}

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Apr 23 2014 22:40:59 GMT+0200 (CEST)