linkedlists-and-nodes
v1.0.1
Published
### Description
Downloads
6
Readme
linked-lists
Description
The package contains:
LinkedList
A factory that when invoked return an empty (null) linked list with functions:
- append(node) : Add the given node to the end of the list
- prepend(node) : Add the given node to the start of the list
- size : Return the number of nodes in the list
- head : Return the first node in the list
- tail : Return the last node in the list
- at(index) : Return the node at the given index
- pop : Remove the last node from the list
- contains(value) : Return true if the value is in the list, false otherwise
- find(value) : Return the index of the node containing the value, null if the value isn't found
- toString : Return a string representation of the list
- insertAt(node, index) : Insert the given node in the list at the given index
- removeAt(index) : Remove the node at the given index
Node
A class that when invoked with an argument value (new Node(value)) returns a node with:
- node.value = value
- node.next = null
These nodes can then be added to the linked list via the LinkedList functions.