/ x / datastructure@1.2.1 / linkedList / doubly

Doubly Linked List Api

DataType<T> = {
    key: string|number
    value: T

// static method that creates a instance of `DoublyLinkedList` class.

// Time Complexity: O(1)
size: number;

// *generator function, it returens an iterator.
iterator(): Generator

// Time Complexity: O(1)
prepend(data: DataType<any>): boolean;
append(data: DataType<any>): boolean;

// Time Complexity: O(n)
add(data: DataType<any>, position: number): boolean;

// Time Complexity: O(1)
getFromHead(): object|false;

// Time Complexity: O(1)
getFromTail(): object|false;

// Time Complexity: O(n)
log(): void;

// Time Complexity:
// head node: O(1), other nodes: O(n)
remove(key: string|number): object|boolean;

// Time Complexity:
// head node & tail: O(1), other nodes: O(n)
update(key: string|number, newValue: any): object|boolean;

// Time Complexity:
// head node & tail node: O(1), other nodes: O(n)
search(key: string|number): object|null


import { DoublyLinkedList } from "";

const doublyLinkedList = DoublyLinkedList.createDL()

// iterator method returns a *generator function
const iterator = doublyLinkedList.iterator()
let iteratorNext =
// console.log(,;
while (iteratorNext.done === false) {
    iteratorNext =

// get the size of the linked list

// insert in the head
doublyLinkedList.prepend({key: 'a', value: 'apple'})
doublyLinkedList.prepend({key: 'b', value: [1, 2, 3]})
doublyLinkedList.prepend({key: 11, value: {name: 'Sourav'}})

// insert in the tail
doublyLinkedList.append({key: 'c', value: 'add to last'})

// insert anywhere except head & tail
doublyLinkedList.add({key: 'x', value: 'X'}, 1)

// get data from head or tail of linked list

// console all values

// remove or delete data from linked list

// update data in linked list
doublyLinkedList.update('a', [1, 4, 8])

// search data in the linked list'Sourav')
Implement different Data Structures using TypeScript. Deno Third-party Module.
GitHub RepositoryAbmSourav/dataStructure
GitHub Stars

Version Info

Tagged at
10 months ago