Class Index | File Index

Classes


Class DoubleLinkedList


Defined in: DataStructures.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Class for managing a double linked list.
Field Summary
Field Attributes Field Name and Description
 
The first node of the list.
 
The last node of the list.
 
The length of the list.
Method Summary
Method Attributes Method Name and Description
 
addAt(item, index)
Adds the item at the index position.
 
allIndexesOf(item, callback)
Returns all the position in which the item has been found in the list.
 
Removes all the items stored in the list.
 
Clones the list into a new list.
 
Clones the list into a new list without cloning duplicated items.
 
contains(item, callback)
Checks if the list contains an item that satisfy the condition represented by the callback function.
 
count(callback)
Returns the number of items that satisfy the represented by the callback function.
 
deleteNode(node)
Deletes the node from the list.
 
divide(index)
Divides the list at the index position.
 
execute(callback)
Executes the callback function for each item of the stack.
 
filter(callback)
Returns the items that satisfy the condition determined by the callback.
 
fromArray(array)
Builds the list from the array.
 
getItem(index)
Gets the item at the position index.
 
Returns the iterator relative to the aggregate.
 
Returns the length of the list.
 
getNode(index, node)
Gets the node at the position index relative from the node.
 
indexOf(item, callback)
Returns the first position of the item in the list.
 
Checks if the list is empty.
 
join(list)
Adds the list at the end of this list.
 
lastIndexOf(item, callback)
Returns the last position of the item in the list.
 
modifyAt(index, item)
Changes the item stored in the index position.
 
multiPopBack(times)
Removes the last times items of the list.
 
Removes the first times items of the list.
 
Sorts the list using web workers.
 
peek()
Returns the first item of the list without remove it.
 
Removes the last item of the list.
 
Removes the first item of the list.
 
pushBack(item)
Adds an item at the tail of the list.
 
pushFront(item)
Adds an item at the head of the list.
 
remove(item, callback)
Removes the item from the list.
 
removeAll(item, callback)
Removes all the item from the list.
 
removeAt(index)
Removes the item at the position index.
 
removeSegment(from, to)
Removes all the items stored from the from position to the to position.
 
Reverses the list.
 
sort(callback)
Sorts the list.
 
split(size)
Splits the list into lists of desired size.
 
Transforms the list into an array.
Class Detail
DoubleLinkedList(args)
Class for managing a double linked list.
Parameters:
{...*} args Optional
The items for initializing the list.
Field Detail
first
The first node of the list.

last
The last node of the list.

length
The length of the list.
Method Detail
{void} addAt(item, index)
Adds the item at the index position.
Parameters:
item
{*} The item to add.
index
{number} The position where to add the item. If index is negative, the item won't be added.
Returns:
{void}

{Array} allIndexesOf(item, callback)
Returns all the position in which the item has been found in the list.
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 list.
Returns:
{void}

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

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

{boolean} contains(item, callback)
Checks if the list 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 list contains the item that satisfy the condition, false otherwise.

{number} count(callback)
Returns the number of items that satisfy the represented by the callback function.
Parameters:
callback
{function} The condition to satisfy.
Returns:
{number} The number of items that satisfy the condition.

{void} deleteNode(node)
Deletes the node from the list.
Parameters:
node
{DLLNode} The node to delete.
Returns:
{void}

{DoubleLinkedList} divide(index)
Divides the list at the index position. The node at the index position is the first new node of the list.
Parameters:
index
{number} The position where to divide the list.
Returns:
{DoubleLinkedList} The list formed by the nodes from the index position then. If the index is out of bound, the list will be empty.

{void} execute(callback)
Executes the callback function for each item of the stack. This method modifies the list 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.
{void} fromArray(array)
Builds the list from the array.
Parameters:
array
{Array<*>} The array from which build the list.
Returns:
{void}

{*} getItem(index)
Gets the item at the position index.
Parameters:
index
{Number} The position of the item.
Returns:
{*} . 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 list.
Returns:
{Number} The length of the list.

{DLLNode} getNode(index, node)
Gets the node at the position index relative from the node.
Parameters:
index
{Number} The index, relative to the node, of the node to return.
node Optional, Default: first
{DLLNode} The node from which start the search.
Returns:
{DLLNode} The node at the position index.

{number} indexOf(item, callback)
Returns the first position of the item in the list.
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 list is empty.
Returns:
{boolean} True if the list is empty, false otherwise.

{void} join(list)
Adds the list at the end of this list.
Parameters:
list
{DoubleLinkedList} The list to join.
Returns:
{void}

{number} lastIndexOf(item, callback)
Returns the last position of the item in the list.
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.

{void} modifyAt(index, item)
Changes the item stored in the index position. If the index is out of bound, the node won't be updated.
Parameters:
index
{number} The position of the node to modify.
item
{*} The new item stored in the node.
Returns:
{void}

{*} multiPopBack(times)
Removes the last times items of the list.
Parameters:
times
{number} The number of times to repeat the popBack method.
Returns:
{*} The items removed.

{*} multiPopFront(times)
Removes the first times items of the list.
Parameters:
times
{number} The number of times to repeat the popFront method.
Returns:
{*} The item removed. It's undefined if the list is empty.

{void} parallelSort()
Sorts the list using web workers. Using this method is discouraged. Many web browser set a limit to the maximum number of workers instantiated. The items of the list, due to web workers implementation, will be serialized so they will lost own methods.
Returns:
{void}

{*} peek()
Returns the first item of the list without remove it.
Returns:
{*} The item at the top of the list. It's undefined if the list is empty.

{*} popBack()
Removes the last item of the list.
Returns:
{*} The item removed. It's undefined if the list is empty.

{*} popFront()
Removes the first item of the list.
Returns:
{*} The item removed. It's undefined if the list is empty.

{void} pushBack(item)
Adds an item at the tail of the list.
Parameters:
item
{*} The item to add.
Returns:
{void}

{void} pushFront(item)
Adds an item at the head of the list.
Parameters:
item
{*} The item to add.
Returns:
{void}

{void} remove(item, callback)
Removes the item from the list.
Parameters:
item
{*} The item to remove.
callback Optional, Default: function(item){return(it===item);}
The condition to satisfy. The callback must accept the current item to check.
Returns:
{void}

{void} removeAll(item, callback)
Removes all the item from the list.
Parameters:
item
{*} The item to remove.
callback Optional, Default: function(item){return(it===item);}
The condition to satisfy. The callback must accept the current item to check.
Returns:
{void}

{*} removeAt(index)
Removes the item at the position index.
Parameters:
index
{Number} The position of the item to remove.
Returns:
{*} The item stored at the position index. It's undefined if the index is out of bounds.

{Array<*>} removeSegment(from, to)
Removes all the items stored from the from position to the to position. If from > to, the method will remove all the items up to the end.
Parameters:
from
{number} The position where start to remove the items. The from position is included.
to
{number} The position where stop to remove the items. The to position is included.
Returns:
{Array<*>} The items removed.

{void} reverse()
Reverses the list. This method reverses only the items, not the nodes.
Returns:
{void}

{void} sort(callback)
Sorts the list.
callback = function(item) {return -item.key;}
This function callback will return the opposite of the attribute key of the item. In this case the list will be sorted in descending order.
Parameters:
callback Optional, Default: function(item){return(item);}
{function} The function invoked in order to get the value for the evaluation of the sort criteria.
Returns:
{void}

{Array} split(size)
Splits the list into lists of desired size.
Parameters:
size
{number} The size of the lists.
Returns:
{Array} The lists created by splitting the list.

{Array<*>} toArray()
Transforms the list into an array.
Returns:
{Array<*>} The array built.

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