DoublyLinkedList Class
The DoublyLinkedList class provides the main functionality of a doubly linked list.
Item Index
Methods
Methods
add
-
index
-
value
Insert a new value at the specified index
Parameters:
-
index
ObjectThe index where the new value is to be inserted.
-
value
ObjectThe new value for the index.
Returns:
void
bottom
()
Peeks at the node from the beginning of the doubly linked list
Returns:
any The value of the first node.
count
()
Counts the number of elements in the doubly linked list
Returns:
number the number of elements in the doubly linked list.
current
()
Return current list entry
Returns:
any The current node value.
isEmpty
()
Checks whether the doubly linked list is empty
Returns:
boolean whether the doubly linked list is empty.
key
()
Return current node index
Returns:
any The current node index.
next
()
Move to next entry
Returns:
void
pop
()
Pops a node from the end of the doubly linked list
Returns:
any The value of the popped node.
prev
()
Move to previous entry
Returns:
void
push
-
value
Pushes an element at the end of the doubly linked list
Parameters:
-
value
ObjectThe value to push.
Returns:
void
rewind
()
Rewind iterator back to the start
Returns:
void
shift
()
Shifts a node from the beginning of the doubly linked list
Returns:
any The value of the shifted node.
toArray
()
Export the list to array
Returns:
Array The exported array
top
()
Peeks at the node from the end of the doubly linked list
Returns:
any The value of the last node.
toString
()
Serializes the list to string
Returns:
string The serialized string.
unshift
-
value
Prepends the doubly linked list with an element
Parameters:
-
value
ObjectThe value to unshift.
Returns:
void
valid
()
Check whether the doubly linked list contains more nodes
Returns:
boolean true if the doubly linked list contains any more nodes, false otherwise.
Properties
_current
DoublyLinkedListNode
private
Reference to iterated element in list
_head
DoublyLinkedListNode
private
Reference to head(first) element in list
_key
Number
private
Iteration pointer
_length
Number
private
Count of elements in list
_tail
DoublyLinkedListNode
private
Reference to tail(last) element in list