Constructor
new LinkedList()
A linked list has a single node that starts off the entire chain. This is known as the "head" of the linked
list
Note that we to store the length separately because the "memory" doesn't have a length that can be read.
- Source:
Methods
add(value, position)
Add nodes to the specified position
Parameters:
| Name | Type | Description |
|---|---|---|
value |
* | Value that should be added to the list |
position |
Number | Postion where the value should be added |
- Source:
get(position) → {null|*|Object}
Retrieve a value in a given position.
This works differently than normal lists as we can't just jump to the correct position. Instead we need to
move through the individual nodes.
Parameters:
| Name | Type | Description |
|---|---|---|
position |
Number | Position of element in List |
- Source:
Returns:
- Type
- null | * | Object
remove(position)
Look up a node by its position and splice it out of the chain.
Parameters:
| Name | Type | Description |
|---|---|---|
position |
Number | Position of node that should be spliced out |
- Source: