LinkedList

LinkedList

Implements a singly linked list. Linked List on Wikipedia

Constructor

new LinkedList(value)

Creates a LinkedList.
Parameters:
Name Type Description
value * A value.
Source:

Methods

append(value) → {LinkedList}

Appends a new value to the tail of the LinkedList.
Parameters:
Name Type Description
value *
Source:
Returns:
this instance.
Type
LinkedList

asArray() → {Array.<any>}

Maps the values to an array, `head.value` is at the 0th index and the `tail.value` is at the ultimate index.
Source:
Returns:
An array of node values.
Type
Array.<any>

insert(index, value) → {LinkedList}

Inserts a value at a particular index
Parameters:
Name Type Description
index number
value any
Source:
Returns:
this instance.
Type
LinkedList

prepend(value) → {LinkedList}

Prepends a new value to the head of the LinkedList.
Parameters:
Name Type Description
value *
Source:
Returns:
this instance.
Type
LinkedList

remove(index) → {LinkedList}

Removes a node at a particular index.
Parameters:
Name Type Description
index number
Source:
Returns:
this instance.
Type
LinkedList

reverse() → {LinkedList}

Reverse a LinkedList in place.
Source:
Returns:
this instance.
Type
LinkedList

traverseToIndex(index) → {LinkedNode}

Traverses to a node at a particular index.
Parameters:
Name Type Description
index number
Source:
Returns:
List Node is returned
Type
LinkedNode