LinkedList

Kind: global class

new LinkedList(root)

Param Default Description
root The root element

linkedList.push(new_ele) ⇒

Method pushes the given element in the Linked List

Kind: instance method of LinkedList
Returns: boolean true, if the push is successful, else false

Param Description
new_ele The new element

linkedList.insertAt(index, new_ele) ⇒

Method lets you insert an element at the given index

Kind: instance method of LinkedList
Returns: boolean true, if the push is successful, else false

Param Description
index The index at which the new element is to be inserted
new_ele The new element

linkedList.get(index) ⇒

Method gets the element at the given index.

Kind: instance method of LinkedList
Returns: Object The object at the given index

Param Description
index the index

linkedList.contains(ele) ⇒

Method checks if the List contains the method passed as the argument

Kind: instance method of LinkedList
Returns: boolean true, if the element is present in the list, else false.

Param Description
ele The element to be checked

linkedList.indexOf(ele) ⇒

Method returns the first index of the given element in the list, else returns -1

Kind: instance method of LinkedList
Returns: int the first index of the element in the list

Param Description
ele The element whose index in the list is to be checked

linkedList.lastIndexOf(ele) ⇒

Method returns the last index of the given element in the list, else returns -1

Kind: instance method of LinkedList
Returns: int the last index of the element in the list

Param Description
ele The element whose last index in the list is to be checked

linkedList.remove(ele) ⇒

Method removes the first occurrence of the given element from the list

Kind: instance method of LinkedList
Returns: Object The object that is removed, or null

Param Description
ele The element which is to be removed from the list

linkedList.removeAt(index) ⇒

Method removes the element from the list at the given index

Kind: instance method of LinkedList
Returns: Object The object that is removed, or null

Param Default Description
index 0 The index at which the element is to be removed

linkedList.pop() ⇒

Method removes the element at the end of the list

Kind: instance method of LinkedList
Returns: Object the removed element

linkedList.shift() ⇒

Method removes the element at the start of the list

Kind: instance method of LinkedList
Returns: Object the removed element

linkedList.peekFirst() ⇒

Method retrieves, but does not remove, the first element of this list, or returns null if this list is empty

Kind: instance method of LinkedList
Returns: Object first element in the list

linkedList.peekLast() ⇒

Method retrieves, but does not remove, the last element of this list, or returns null if this list is empty

Kind: instance method of LinkedList
Returns: Object last element in the list

linkedList.concat(array)

Method merges the given array with the list.

Kind: instance method of LinkedList

Param Description
array the array to be merged

linkedList.toArray() ⇒

Method returns the contents of the list as an array

Kind: instance method of LinkedList
Returns: Array the contents of the list