This is a standalone Doubly Linked List data structure from the data-structure-typed collection. If you wish to access
more data structures or advanced features, you can transition to directly installing the
complete data-structure-typed package
How
install
npm
npm i doubly-linked-list-typed --save
yarn
yarnadd doubly-linked-list-typed
snippet
basic DoublyLinkedList creation and push operation
// Create a simple DoublyLinkedList with initial valuesconst list =newDoublyLinkedList([1,2,3,4,5]);// Verify the list maintains insertion orderconsole.log([...list]);// [1, 2, 3, 4, 5];// Check lengthconsole.log(list.length);// 5;// Push a new element to the end
list.push(6);console.log(list.length);// 6;console.log([...list]);// [1, 2, 3, 4, 5, 6];
DoublyLinkedList pop and shift operations
const list =newDoublyLinkedList<number>([10,20,30,40,50]);// Pop removes from the endconst last = list.pop();console.log(last);// 50;// Shift removes from the beginningconst first = list.shift();console.log(first);// 10;// Verify remaining elementsconsole.log([...list]);// [20, 30, 40];console.log(list.length);// 3;
DoublyLinkedList for...of iteration and map operation
const list =newDoublyLinkedList<number>([1,2,3,4,5]);// Iterate through listconst doubled = list.map(value => value *2);console.log(doubled.length);// 5;// Use for...of loopconst result:number[]=[];for(const item of list){
result.push(item);}console.log(result);// [1, 2, 3, 4, 5];
Follows ES6 and ESNext standards, offering unified and considerate optional parameters, and simplifies method names.
Extensibility
Adheres to OOP (Object-Oriented Programming) principles, allowing inheritance for all data structures.
Modularization
Includes data structure modularization and independent NPM packages.
Efficiency
All methods provide time and space complexity, comparable to native JS performance.
Maintainability
Follows open-source community development standards, complete documentation, continuous integration, and adheres to TDD (Test-Driven Development) patterns.
Testability
Automated and customized unit testing, performance testing, and integration testing.
Portability
Plans for porting to Java, Python, and C++, currently achieved to 80%.
Reusability
Fully decoupled, minimized side effects, and adheres to OOP.
Security
Carefully designed security for member variables and methods. Read-write separation. Data structure software does not need to consider other security aspects.
Scalability
Data structure software does not involve load issues.