Class Index | File Index

Classes


Class buckets.LinkedList

A linked list is a data structure consisting of a group of nodes which together represent a sequence.
Defined in: <../buckets.js>.

Class Summary
Constructor Attributes Constructor Name and Description
 
Creates an empty Linked List.
Method Summary
Method Attributes Method Name and Description
 
add(item, index)
Adds an element to this list.
 
Removes all the elements from this list.
 
contains(item, equalsFunction)
Returns true if this list contains the specified element.
 
Returns the element at the specified position in this list.
 
equals(other, equalsFunction)
Returns true if this list is equal to the given list.
 
Returns the first element in this list.
 
forEach(callback)
Executes the provided function once per element present in this list in order.
 
indexOf(item, equalsFunction)
Returns the index of the first occurrence of the specified element, or -1 if the List does not contain this element.
 
Returns true if this list contains no elements.
 
last()
Returns the last element in this list.
 
remove(item, equalsFunction)
Removes the first occurrence of the specified element in this list.
 
Removes the element at the specified position in this list.
 
Reverses the order of the elements in this linked list (makes the last element first, and the first element last).
 
size()
Returns the number of elements in this list.
 
Returns an array containing all of the elements in this list in proper sequence.
Class Detail
buckets.LinkedList()
Creates an empty Linked List.
Method Detail
{boolean} add(item, index)
Adds an element to this list.
Parameters:
{Object} item
Element to be added.
{number=} index
Optional index to add the element. If no index is specified the element is added to the end of this list.
Returns:
{boolean} True if the element was added or false if the index is invalid or if the element is undefined.

clear()
Removes all the elements from this list.

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

If the elements inside the list 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} item
Element to search for.
{function(Object|Object):boolean=} equalsFunction
Optional function used to check if two elements are equal.
Returns:
{boolean} True if this list contains the specified element, false otherwise.

{*} elementAtIndex(index)
Returns the element at the specified position in this list.
Parameters:
{number} index
Desired index.
Returns:
{*} The element at the given index or undefined if the index is out of bounds.

{boolean} equals(other, equalsFunction)
Returns true if this list is equal to the given list. Two lists are equal if they have the same elements in the same order.
Parameters:
{buckets.LinkedList} other
The other list.
{function(Object|Object):boolean=} equalsFunction
Optional function to check if two elements are equal. If the elements in the lists are custom objects you should provide a function, otherwise the === operator is used to check equality between elements.
Returns:
{boolean} true if this list is equal to the given list.

{*} first()
Returns the first element in this list.
Returns:
{*} The first element of the list or undefined if the list is empty.

forEach(callback)
Executes the provided function once per element present in this list in 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.

{number} indexOf(item, equalsFunction)
Returns the index of the first occurrence of the specified element, or -1 if the List does not contain this element.

If the elements inside this list 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} item
Element to search for.
{function(Object|Object):boolean=} equalsFunction
Optional function used to check if two elements are equal.
Returns:
{number} The index in this list of the first occurrence of the specified element, or -1 if this list does not contain the element.

{boolean} isEmpty()
Returns true if this list contains no elements.
Returns:
{boolean} true if this list contains no elements.

{*} last()
Returns the last element in this list.
Returns:
{*} The last element in the list or undefined if the list is empty.

{boolean} remove(item, equalsFunction)
Removes the first occurrence of the specified element in this list.

If the elements inside the list 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} item
Element to be removed from this list, if present.
equalsFunction
Returns:
{boolean} True if the list contained the specified element.

{*} removeElementAtIndex(index)
Removes the element at the specified position in this list.
Parameters:
{number} index
Given index.
Returns:
{*} Removed element or undefined if the index is out of bounds.

reverse()
Reverses the order of the elements in this linked list (makes the last element first, and the first element last).

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

{Array.<*>} toArray()
Returns an array containing all of the elements in this list in proper sequence.
Returns:
{Array.<*>} An array containing all of the elements in this list, in proper sequence.

Documentation generated by JsDoc Toolkit 2.4.0 on Thu Mar 12 2015 00:38:48 GMT-0500 (COT)