Class Index | File Index

Classes


Class LinkedList


Defined in: DataStructures.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
LinkedList(args)
Class for managing a 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.
 
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)
Returns the item at the position index.
 
Returns the iterator relative to the aggregate.
 
Returns the length of the list.
 
getNode(index)
Returns the node at the position index.
 
indexOf(item, callback)
Returns the first position of the item in the list.
 
Checks if the list is empty.
 
join(list)
Joins 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.
 
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 index position.
 
removeSegment(from, to)
Removes all the items stored from the from position to the to position.
 
split(size)
Splits the list into lists of desired size.
 
Transforms the list into an array.
Class Detail
LinkedList(args)
Class for managing a 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}

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

{LinkedList} cloneDistinct()
Clones the list into a new list without cloning duplicated items.
Returns:
{LinkedList} 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.

{LinkedList} 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:
{LinkedList} 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)
Returns the item at the position index.
Parameters:
index
{number} The position of the item.
Returns:
{*} The item stored at the position index. It's undefined if index isn't in the list 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.

{LLNode} getNode(index)
Returns the node at the position index.
Parameters:
index
{number} The position of the node.
Returns:
{LLNode} The node stored at the position index. It's undefined if index isn't in the list bounds.

{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)
Joins the list at the end of this list.
Parameters:
list
{LinkedList} 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.

{*} 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 index position.
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.

{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:59 GMT+0200 (CEST)