A doubly linked list in JavaScript.
const ParrotDll = require("parrot-dll");
const addressList = ParrotDll();
addressList.add({ name: 'Bruce Lee', street: 'Kung Fu Street 12' });
addressList.add({ name: 'John Snow', street: 'Winterfell 1' });
console.log(addressList.size()) // "2"
console.log(addressList.get(0).name) // "Bruce Lee"
console.log(addressList.get(1).name) // "John Snow"
addressList.remove(0);
console.log(addressList.size()) // "1"
console.log(addressList.get(0).name) // "John Snow"
add(object: any): void
Adds an object to the listsize(): number
Returns the size of the listget(index: integer): any
Returns object at given index. If index is out of bounds it returns null.remove(index: integer): any
Removes the object at given index from the list and returns the removed object. If the index is out of bounds it returns null.
add
: O(1)size
: O(1)get
: O(n)remove
: O(n)