A full-featured doubly-linked list implementation.
Install from NPM with
$ npm install --save @jsdsl/doubly-linked-list
A basic use case would be as follows:
import { DoublyLinkedList, DoublyLinkedListNode } from "@jsdsl/doubly-linked-list";
// Initialize the doubly-linked list.
let dll: DoublyLinkedList<string> = new DoublyLinkedList<string>();
// Add an element: 'turtle'
dll.add("turtle");
// Add at element at the beginning of the list.
let catNode: DoublyLinkedListNode<E> = dll.insertFirst("cat");
// Insert an element, 'dog', after the 'cat' element.
dll.insertAfter("dog", catNode);
// The list's current state:
// 'cat' <--> 'dog' <--> 'turtle'
See the wiki for full documentation.
@jsdsl/doubly-linked-list is made available under the GNU General Public License v3.
Copyright (C) 2019 Trevor Sears