diff --git a/README.md b/README.md index b283815..72e3883 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,27 @@ # What ## Brief -Javascript & TypeScript Data Structure Library. +Javascript & TypeScript Data Structure collections. -Binary Tree, Binary Search Tree (BST), AVL Tree, Tree Multiset, Segment Tree, Binary Indexed Tree, Graph, Directed Graph, Undirected Graph, Linked List, Singly Linked List, Doubly Linked List, Queue, Object Deque, Array Deque, Stack, Hash, Coordinate Set, Coordinate Map, Heap, Priority Queue, Max Priority Queue, Min Priority Queue, Trie +## Algorithms -## Algorithms list only a few out, you can discover more in API docs - -DFS, DFSIterative, BFS, morris, Bellman-Ford Algorithm, Dijkstra's Algorithm, Floyd-Warshall Algorithm, Tarjan's Algorithm +DFS, DFSIterative, BFS, morris, Bellman-Ford Algorithm, Dijkstra's Algorithm, Floyd-Warshall Algorithm, Tarjan's Algorithm. Listed only a few out, you can discover more in API docs ## Code design By strictly adhering to object-oriented design (BinaryTree -> BST -> AVLTree -> TreeMultiset), you can seamlessly inherit the existing data structures to implement the customized ones you need. Object-oriented design stands as the optimal approach to data structure design. # How - +### npm +```bash +npm install data-structure-typed +``` ## install ### yarn - ```bash yarn add data-structure-typed ``` -### npm -```bash -npm install data-structure-typed -``` ### Binary Search Tree (BST) snippet diff --git a/package.json b/package.json index 067586c..6c4919f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "data-structure-typed", - "version": "1.19.5", + "version": "1.19.7", "description": "Javascript & TypeScript Data Structure Library, meticulously crafted to empower developers with a versatile set of essential data structures. Our library includes a wide range of data structures, such as Binary Tree, AVL Tree, Binary Search Tree (BST), Tree Multiset, Segment Tree, Binary Indexed Tree, Graph, Directed Graph, Undirected Graph, Singly Linked List, Hash, CoordinateSet, CoordinateMap, Heap, Doubly Linked List, Priority Queue, Max Priority Queue, Min Priority Queue, Queue, ObjectDeque, ArrayDeque, Stack, and Trie. Each data structure is thoughtfully designed and implemented using TypeScript to provide efficient, reliable, and easy-to-use solutions for your programming needs. Whether you're optimizing algorithms, managing data, or enhancing performance, our TypeScript Data Structure Library is your go-to resource. Elevate your coding experience with these fundamental building blocks for software development.", "main": "dist/index.js", "scripts": { @@ -65,9 +65,9 @@ "typescript": "^4.9.5" }, "dependencies": { - "avl-tree-typed": "^1.19.5", - "bst-typed": "^1.19.5", - "heap-typed": "^1.19.5", + "avl-tree-typed": "^1.19.6", + "bst-typed": "^1.19.6", + "heap-typed": "^1.19.6", "zod": "^3.22.2" } } diff --git a/src/data-structures/binary-tree/diagrams/avl-tree-inserting.gif b/src/data-structures/binary-tree/diagrams/avl-tree-inserting.gif deleted file mode 100644 index 46a3d48..0000000 Binary files a/src/data-structures/binary-tree/diagrams/avl-tree-inserting.gif and /dev/null differ diff --git a/src/data-structures/binary-tree/diagrams/bst-rotation.gif b/src/data-structures/binary-tree/diagrams/bst-rotation.gif deleted file mode 100644 index a314ba8..0000000 Binary files a/src/data-structures/binary-tree/diagrams/bst-rotation.gif and /dev/null differ diff --git a/src/data-structures/binary-tree/diagrams/segment-tree.png b/src/data-structures/binary-tree/diagrams/segment-tree.png deleted file mode 100644 index c02cc27..0000000 Binary files a/src/data-structures/binary-tree/diagrams/segment-tree.png and /dev/null differ diff --git a/src/data-structures/graph/abstract-graph.ts b/src/data-structures/graph/abstract-graph.ts index a2d8962..99e105d 100644 --- a/src/data-structures/graph/abstract-graph.ts +++ b/src/data-structures/graph/abstract-graph.ts @@ -170,7 +170,6 @@ export abstract class AbstractGraph, E extends Abs addVertex(idOrVertex: VertexId | V, val?: V['val']): boolean { if (idOrVertex instanceof AbstractVertex) { return this._addVertexOnly(idOrVertex); - } else { const newVertex = this.createVertex(idOrVertex, val); return this._addVertexOnly(newVertex); diff --git a/src/data-structures/graph/diagrams/adjacency-list-pros-cons.jpg b/src/data-structures/graph/diagrams/adjacency-list-pros-cons.jpg deleted file mode 100644 index 711da3d..0000000 Binary files a/src/data-structures/graph/diagrams/adjacency-list-pros-cons.jpg and /dev/null differ diff --git a/src/data-structures/graph/diagrams/adjacency-list.jpg b/src/data-structures/graph/diagrams/adjacency-list.jpg deleted file mode 100644 index 1deb981..0000000 Binary files a/src/data-structures/graph/diagrams/adjacency-list.jpg and /dev/null differ diff --git a/src/data-structures/graph/diagrams/adjacency-matrix-pros-cons.jpg b/src/data-structures/graph/diagrams/adjacency-matrix-pros-cons.jpg deleted file mode 100644 index 156eee3..0000000 Binary files a/src/data-structures/graph/diagrams/adjacency-matrix-pros-cons.jpg and /dev/null differ diff --git a/src/data-structures/graph/diagrams/adjacency-matrix.jpg b/src/data-structures/graph/diagrams/adjacency-matrix.jpg deleted file mode 100644 index c1ac916..0000000 Binary files a/src/data-structures/graph/diagrams/adjacency-matrix.jpg and /dev/null differ diff --git a/src/data-structures/graph/diagrams/dfs-can-do.jpg b/src/data-structures/graph/diagrams/dfs-can-do.jpg deleted file mode 100644 index fa169ce..0000000 Binary files a/src/data-structures/graph/diagrams/dfs-can-do.jpg and /dev/null differ diff --git a/src/data-structures/graph/diagrams/edge-list-pros-cons.jpg b/src/data-structures/graph/diagrams/edge-list-pros-cons.jpg deleted file mode 100644 index 80ccc4c..0000000 Binary files a/src/data-structures/graph/diagrams/edge-list-pros-cons.jpg and /dev/null differ diff --git a/src/data-structures/graph/diagrams/edge-list.jpg b/src/data-structures/graph/diagrams/edge-list.jpg deleted file mode 100644 index 0baedec..0000000 Binary files a/src/data-structures/graph/diagrams/edge-list.jpg and /dev/null differ diff --git a/src/data-structures/graph/diagrams/max-flow.jpg b/src/data-structures/graph/diagrams/max-flow.jpg deleted file mode 100644 index 65a9914..0000000 Binary files a/src/data-structures/graph/diagrams/max-flow.jpg and /dev/null differ diff --git a/src/data-structures/graph/diagrams/mst.jpg b/src/data-structures/graph/diagrams/mst.jpg deleted file mode 100644 index a143d91..0000000 Binary files a/src/data-structures/graph/diagrams/mst.jpg and /dev/null differ diff --git a/src/data-structures/graph/diagrams/tarjan-articulation-point-bridge.png b/src/data-structures/graph/diagrams/tarjan-articulation-point-bridge.png deleted file mode 100644 index e049d59..0000000 Binary files a/src/data-structures/graph/diagrams/tarjan-articulation-point-bridge.png and /dev/null differ diff --git a/src/data-structures/graph/diagrams/tarjan-complicate-simple.png b/src/data-structures/graph/diagrams/tarjan-complicate-simple.png deleted file mode 100644 index 5022bcb..0000000 Binary files a/src/data-structures/graph/diagrams/tarjan-complicate-simple.png and /dev/null differ diff --git a/src/data-structures/graph/diagrams/tarjan-strongly-connected-component.png b/src/data-structures/graph/diagrams/tarjan-strongly-connected-component.png deleted file mode 100644 index 1658f3a..0000000 Binary files a/src/data-structures/graph/diagrams/tarjan-strongly-connected-component.png and /dev/null differ diff --git a/src/data-structures/graph/diagrams/tarjan.mp4 b/src/data-structures/graph/diagrams/tarjan.mp4 deleted file mode 100644 index 032b6a3..0000000 Binary files a/src/data-structures/graph/diagrams/tarjan.mp4 and /dev/null differ diff --git a/src/data-structures/graph/diagrams/tarjan.webp b/src/data-structures/graph/diagrams/tarjan.webp deleted file mode 100644 index fdb630c..0000000 Binary files a/src/data-structures/graph/diagrams/tarjan.webp and /dev/null differ diff --git a/src/data-structures/heap/heap.ts b/src/data-structures/heap/heap.ts index 4e47546..d311198 100644 --- a/src/data-structures/heap/heap.ts +++ b/src/data-structures/heap/heap.ts @@ -44,9 +44,9 @@ export class HeapItem { } export abstract class Heap { + /** - * The function is a constructor for a class that initializes a priority callback function based on the - * options provided. + * The constructor function initializes a priority queue with an optional priority extractor function. * @param [options] - An optional object that contains configuration options for the Heap. */ protected constructor(options?: HeapOptions) { @@ -91,9 +91,16 @@ export abstract class Heap { peek(isItem?: undefined): T | undefined; peek(isItem: false): T | undefined; peek(isItem: true): HeapItem | null; + /** - * The `peek` function returns the top item in the priority queue without removing it. - * @returns The `peek()` method is returning either a `HeapItem` object or `null`.Returns an val with the highest priority in the queue + * The `peek` function returns the top item or value in a priority queue, depending on the value of the `isItem` + * parameter. + * @param {boolean} [isItem] - The `isItem` parameter is an optional boolean parameter that determines whether the + * method should return the entire `HeapItem` object or just the value of the item. If `isItem` is set to `true`, the + * method will return the `HeapItem` object. If `isItem` + * @returns The `peek` method returns either a `HeapItem` object, `null`, `T`, or `undefined`. The specific return + * type depends on the value of the `isItem` parameter. If `isItem` is `true`, then the method returns a `HeapItem` + * object or `null` if the heap is empty. If `isItem` is `false` */ peek(isItem?: boolean): HeapItem | null | T | undefined { isItem = isItem ?? false; @@ -104,9 +111,16 @@ export abstract class Heap { peekLast(isItem?: undefined): T | undefined; peekLast(isItem: false): T | undefined; peekLast(isItem: true): HeapItem | null; + /** - * The `peekLast` function returns the last item in the heap. - * @returns The method `peekLast()` returns either a `HeapItem` object or `null`.Returns an val with the lowest priority in the queue + * The `peekLast` function returns the last item in the heap, either as a `HeapItem` object or just the value depending + * on the `isItem` parameter. + * @param {boolean} [isItem] - A boolean parameter that indicates whether the method should return the HeapItem object + * or just the value of the last item in the heap. If isItem is true, the method will return the HeapItem object. If + * isItem is false or not provided, the method will return the value of the last item + * @returns The method `peekLast` returns either a `HeapItem` object, `null`, `T`, or `undefined`. The specific + * return type depends on the value of the `isItem` parameter. If `isItem` is `true`, then the method returns a + * `HeapItem` object or `null` if there are no items in the heap. If `isItem` */ peekLast(isItem?: boolean): HeapItem | null | T | undefined { isItem = isItem ?? false; @@ -133,9 +147,15 @@ export abstract class Heap { poll(isItem?: undefined): T | undefined; poll(isItem: false): T | undefined; poll(isItem: true): HeapItem | null; + /** - * The `poll` function returns the top item from a priority queue or null if the queue is empty.Removes and returns an val with the highest priority in the queue - * @returns either a HeapItem object or null. + * The `poll` function returns the top item from a priority queue, either as a HeapItem object or its value, depending + * on the value of the `isItem` parameter. + * @param {boolean} [isItem] - The `isItem` parameter is a boolean flag that indicates whether the returned value + * should be a `HeapItem` object or just the value `T` itself. If `isItem` is `true`, the method will return the + * `HeapItem` object, otherwise it will return just + * @returns The function `poll` returns either a `HeapItem` object, `null`, or `T` (the value of the `val` property + * of the `HeapItem` object). */ poll(isItem?: boolean): HeapItem | null | T | undefined { isItem = isItem ?? false; @@ -147,8 +167,8 @@ export abstract class Heap { } /** - * The function checks if a given node or value exists in the priority queue. - * @param {T | HeapItem} node - The parameter `node` can be of type `T` or `HeapItem`. + * The `has` function checks if a given node or value exists in the priority queue. + * @param {T | HeapItem} node - The `node` parameter can be of type `T` or `HeapItem`. * @returns a boolean value. */ has(node: T | HeapItem): boolean { @@ -164,9 +184,15 @@ export abstract class Heap { toArray(isItem?: undefined): (T | undefined)[]; toArray(isItem: false): (T | undefined)[]; toArray(isItem: true): (HeapItem | null)[]; + /** - * The `toArray` function returns an array of `HeapItem` objects. - * @returns An array of HeapItem objects.Returns a sorted list of vals + * The `toArray` function returns an array of either HeapItem objects or their values, depending on the value of the + * `isItem` parameter. + * @param {boolean} [isItem] - isItem is an optional boolean parameter that determines whether the returned array + * should contain the HeapItem objects or just the values of the HeapItem objects. If isItem is true, the array will + * contain the HeapItem objects. If isItem is false or not provided, the array will contain only the values + * @returns The method `toArray` returns an array of `HeapItem` objects, or an array of `T` values if the `isItem` + * parameter is set to `false`. */ toArray(isItem?: boolean): (HeapItem | null | T | undefined)[] { isItem = isItem ?? false;