Doubly linked list implementation.
npm install @serayaeryn/linkedlist
const LinkedList = require('@serayaeryn/linkedlist');
const linkedList = new LinkedList();
linkedList.add('a');
linkedList.add('b');
for (const element of linkedList) {
console.log(element);
}
linkedList.remove(0);
Reflects the number of elements in the linked list.
Removes the first element from the linked list and returns that element.
Removes the last element from the linked list and returns that element.
Adds the element
to the front of the linked list.
Adds the element
to the end of the linked list.
Adds the element
at the specified index
of the linked list. If no index
is specified the element
will be added at the end of the linked list.
Adds the elements
at the specified index
of the linked list. If no index
is specified the elements
will be added at the end of the linked list.
Removes all elements from the linked list.
Returns the element at index
.
Sets the element
at the specified index
and returns the element
Removes the element at index
.
Returns the first (least) index of an element within the linked list equal to the specified value, or -1 if none is found.
Returns the last (greatest) index of an element within the linked list equal to the specified value, or -1 if none is found.
Determines whether a linked list contains a certain element.
Returns a string representing the linked list and its elements.