namastey-circular-linked-list
v1.0.1
Published
A package implementing Circular Linked List data structure with various important methods.
Downloads
6
Maintainers
Readme
namastey-circular-linked-list
Brief Description
namastey-circular-linked-list
is a JavaScript package that provides an implementation of the Circular Linked List data structure. It includes various methods for manipulating and interacting with the list.
Features
- append(value): Adds a new node with the specified value to the end of the list.
- insertAt(value, position): Inserts a new node with the specified value at the given position.
- remove(value): Removes the first node with the specified value from the list.
- find(value): Finds and returns the node with the specified value.
- printList(): Prints the entire list to the console.
- getSize(): Returns the number of nodes in the list.
Installation
To install the package globally, run:
npm install -g namastey-circular-linked-list
Examples
const CircularLinkedList = require('namastey-circular-linked-list');
const list = new CircularLinkedList();
list.append(10);
list.append(20);
list.append(30);
list.insertAt(15, 1);
list.printList(); // Output: 10 -> 15 -> 20 -> 30 -> (head)
console.log('Size of list:', list.getSize()); // Output: Size of list: 4
list.remove(20);
list.printList(); // Output: 10 -> 15 -> 30 -> (head)