Class Index | File Index

Classes


Class PriorityQueue


Defined in: DataStructures.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Class for managing a priority queue.
Field Summary
Field Attributes Field Name and Description
 
The list of the items in the queue.
 
The length of the queue.
Method Summary
Method Attributes Method Name and Description
 
changePriority(index, newPriority)
Changes the priority of the item at the position index.
 
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.
 
containsPriority(priority, callback)
Checks if the queue contains a priority that satisfy the condition represented by the callback function.
 
Removes the item at the head of the queue.
 
enqueue(priority, 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.
 
getItems(priority)
Returns the items relatives to the priority.
 
Returns the iterator relative to the aggregate.
 
Returns the length of the queue.
 
Checks if the queue is empty.
 
multiDequeue(times)
Removes the items at the head of the queue.
 
multiEnqueue(priority, items)
Adds the items with the same priority 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.
 
Returns the queue created by the priority queue with the items in the same order but without the priority.
Class Detail
PriorityQueue()
Class for managing a priority queue.
Field Detail
items
The list of the items in the queue.

length
The length of the queue.
Method Detail
{void} changePriority(index, newPriority)
Changes the priority of the item at the position index.
Parameters:
index
{number} The position of the item of which increase the priority.
newPriority
{number} The new priority.
Returns:
{void}

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

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

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

{boolean} containsPriority(priority, callback)
Checks if the queue contains a priority that satisfy the condition represented by the callback function.
Parameters:
priority
{number} The priority to find.
callback Optional, Default: function(p){return(p===priority);}
The condition to satisfy. The callback must accept the current priority to check.
Returns:
{boolean} True if the queue contains the priority 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(priority, item)
Adds the item at the tail of the queue.
Parameters:
priority
{number} The priority of the item.
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 index of the item.
Returns:
{*} The item found. It's undefined if the position index is out of bounds.

{Array<*>} getItems(priority)
Returns the items relatives to the priority.
Parameters:
priority
{number} The priority of the items.
Returns:
{Array<*>} The items found.

{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.

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

{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(priority, items)
Adds the items with the same priority at the tail of the queue.
Parameters:
priority
{number} The priority of the items.
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}

{Queue} toQueue()
Returns the queue created by the priority queue with the items in the same order but without the priority.
Returns:
{Queue} The queue created.

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