1.0.1 • Published 3 months ago

@d1g1tal/collections v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
3 months ago

collections

JavaScript Collections and Data Structures

This is a collection of JavaScript data structures and algorithms. The goal is to provide a comprehensive set of data structures and algorithms that can be used in JavaScript programs.

Installation

npm install @d1g1tal/collections

Usage

List

import { List } from '@d1g1tal/collections';

const list = new List();
list.add(1);
list.add(2);
list.add(3);
list.add(4);
list.add(5);

list.forEach((value) => {
	console.log(value); // 1, 2, 3, 4, 5
});

list.remove(3);

list.forEach((value) => {
	console.log(value); // 1, 2, 4, 5
});

LinkedList

import { LinkedList } from '@d1g1tal/collections';

const linkedList = new LinkedList();
linkedList.add(1);
linkedList.add(2);
linkedList.add(3);
linkedList.add(4);
linkedList.add(5);

linkedList.forEach((value) => {
	console.log(value); // 1, 2, 3, 4, 5
});

linkedList.remove(3);

linkedList.forEach((value) => {
	console.log(value); // 1, 2, 4, 5
});

linkedList.clear();

linkedList.forEach((value) => {
	console.log(value); // nothing
});

console.log(linkedList.size); // 0

Doubly Linked List

const doublyLinkedList = new LinkedList(LinkedList.Type.Doubly);

doublyLinkedList.add(1);
doublyLinkedList.add(2);
doublyLinkedList.add(3);
doublyLinkedList.add(4);
doublyLinkedList.add(5);

doublyLinkedList.forEach((value) => {
	console.log(value); // 1, 2, 3, 4, 5
});

doublyLinkedList.reverse();

doublyLinkedList.forEach((value) => {
	console.log(value); // 5, 4, 3, 2, 1
});
1.0.1

3 months ago

1.0.0

5 months ago

0.2.3

10 months ago

0.2.5

6 months ago

0.2.4

7 months ago

0.1.0

12 months ago

0.2.1

11 months ago

0.1.2

11 months ago

0.2.0

11 months ago

0.1.1

11 months ago

0.0.5

12 months ago

0.2.2

11 months ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago