A doubly linked list is a linked data structure that consists of a set of sequentially linked records called nodes. Each node contains its value and two fields, called links, that are references to the previous and to the next node in the sequence of nodes.
A doubly linked list implemented here has following methods:
addToHead(value)
- creates a new node with a data value ofvalue
and adds it to the start of the list. Returns the new node.addToTail(value)
- creates a new node with a data value ofvalue
and adds it to the end of the list. Returns the new node.getHead()
- returns the node at thehead
of the list.getSize()
- returns the size of the list.getTail()
- returns the node at thetail
of the list.indexOf(value)
- finds an index (or indexes in case of multiple items have the same value) ofvalue
. Returns the index(es);removeHead()
- removes the currenthead
from the list. Returns the value of the removedhead
.removeTail()
- removes the currenttail
from the list. Returns the value of the removedtail
.search(searchValue)
- searches for a node with specifiedsearchValue
. Return the value of node (ornull
if the node wasn't found).