Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: 📝 documentation update #25

Merged
merged 2 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A comprehensive collection of generic data structure implementations which are not supported natively by the for TypeScript/JavaScript, and published on JSR.

[![codecov](https://codecov.io/gh/mandy8055/data-structures/branch/main/graph/badge.svg)](https://codecov.io/gh/mandy8055/data-structures)
[![JSR](https://jsr.io/badges/@mskr/data-structures)](https://jsr.io/@mskr/data-structures) [![JSR Score](https://jsr.io/badges/@mskr/data-structures/score)](https://jsr.io/@mskr/data-structures) [![codecov](https://codecov.io/gh/mandy8055/data-structures/branch/main/graph/badge.svg)](https://codecov.io/gh/mandy8055/data-structures) [![CI](https://github.com/mandy8055/data-structures/actions/workflows/workflow.yml/badge.svg)](https://github.com/mandy8055/data-structures/actions/workflows/workflow.yml)

## Features

Expand Down
20 changes: 18 additions & 2 deletions src/core/binary-heap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,15 @@ import { compareNumbers, compareStrings } from '../utils/index.ts';
* ```
*/
export abstract class BinaryHeap<T> implements Iterable<T> {
/** Heap array which stores the elements */
/**
* @ignore
* Heap array which stores the elements
*/
protected heap: T[];
/** Custom Comparator that can be passed to Heap */
/**
* @ignore
* Custom Comparator that can be passed to Heap
*/
protected compare: (a: T, b: T) => number;

/**
Expand Down Expand Up @@ -126,6 +132,7 @@ export abstract class BinaryHeap<T> implements Iterable<T> {
}

/**
* @ignore
* Creates an iterator for the heap (level-order traversal)
*/
[Symbol.iterator](): Iterator<T> {
Expand Down Expand Up @@ -160,6 +167,7 @@ export abstract class BinaryHeap<T> implements Iterable<T> {
}

/**
* @ignore
* Gets the parent index for a given child index
* @protected
*/
Expand All @@ -168,6 +176,7 @@ export abstract class BinaryHeap<T> implements Iterable<T> {
}

/**
* @ignore
* Gets the left child index for a given parent index
* @protected
*/
Expand All @@ -176,6 +185,7 @@ export abstract class BinaryHeap<T> implements Iterable<T> {
}

/**
* @ignore
* Gets the right child index for a given parent index
* @protected
*/
Expand All @@ -184,12 +194,14 @@ export abstract class BinaryHeap<T> implements Iterable<T> {
}

/**
* @ignore
* Moves an element up the heap until heap property is satisfied
* @protected
*/
protected abstract siftUp(index: number): void;

/**
* @ignore
* Moves an element down the heap until heap property is satisfied
* @protected
*/
Expand All @@ -202,6 +214,7 @@ export abstract class BinaryHeap<T> implements Iterable<T> {
*/
export class MinHeap<T> extends BinaryHeap<T> {
/**
* @ignore
* Moves an element up in the heap until it is in the correct position
* to maintain the min heap property (parent is smaller than or equal to children)
* @protected
Expand All @@ -223,6 +236,7 @@ export class MinHeap<T> extends BinaryHeap<T> {
}

/**
* @ignore
* Moves an element down in the heap until it is in the correct position
* to maintain the min heap property (parent is smaller than or equal to children)
* @protected
Expand Down Expand Up @@ -267,6 +281,7 @@ export class MinHeap<T> extends BinaryHeap<T> {
*/
export class MaxHeap<T> extends BinaryHeap<T> {
/**
* @ignore
* Moves an element up in the heap until it is in the correct position
* to maintain the max heap property (parent is larger than or equal to children)
* @protected
Expand All @@ -288,6 +303,7 @@ export class MaxHeap<T> extends BinaryHeap<T> {
}

/**
* @ignore
* Moves an element down in the heap until it is in the correct position
* to maintain the max heap property (parent is larger than or equal to children)
* @protected
Expand Down
1 change: 1 addition & 0 deletions src/core/deque.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export class Deque<T> implements Iterable<T> {
}

/**
* @ignore
* Creates a forward iterator for the deque (front to back)
*/
[Symbol.iterator](): Iterator<T> {
Expand Down
2 changes: 2 additions & 0 deletions src/core/doubly-linked-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class DoublyLinkedList<T> {
private count = 0;

/**
* @ignore
* Creates a new node with the given value
* @private
*/
Expand Down Expand Up @@ -313,6 +314,7 @@ export class DoublyLinkedList<T> {
}

/**
* @ignore
* Creates a forward iterator for the list
*/
*[Symbol.iterator](): Iterator<T> {
Expand Down
2 changes: 2 additions & 0 deletions src/core/linked-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class LinkedList<T> {
private count = 0;

/**
* @ignore
* Creates a new node with the given value
*/
private createNode(value: T): LinkedListNode<T> {
Expand Down Expand Up @@ -259,6 +260,7 @@ export class LinkedList<T> {
}

/**
* @ignore
* Creates an iterator for the list
*/
*[Symbol.iterator](): Iterator<T> {
Expand Down
1 change: 1 addition & 0 deletions src/core/priority-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export class PriorityQueue<T> implements Iterable<T> {
}

/**
* @ignore
* Creates an iterator for the queue
* Note: Iteration order is based on the internal heap structure,
* not necessarily in priority order
Expand Down
12 changes: 12 additions & 0 deletions src/core/red-black-tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export class RedBlackTree<T> implements Iterable<T> {
}

/**
* @ignore
* Creates a new node with the given value
* @private
* @param value The value to store in the node
Expand Down Expand Up @@ -228,6 +229,7 @@ export class RedBlackTree<T> implements Iterable<T> {
}

/**
* @ignore
* Creates an iterator that traverses the tree in-order
*/
[Symbol.iterator](): Iterator<T> {
Expand All @@ -245,6 +247,7 @@ export class RedBlackTree<T> implements Iterable<T> {
}

/**
* @ignore
* Default comparison function for values
* @private
* @param a First value to compare
Expand All @@ -258,6 +261,7 @@ export class RedBlackTree<T> implements Iterable<T> {
}

/**
* @ignore
* Finds a node with the given value in the tree
* @private
* @param value The value to search for
Expand All @@ -276,6 +280,7 @@ export class RedBlackTree<T> implements Iterable<T> {
}

/**
* @ignore
* Performs a left rotation on the given node
* @private
* @param node The node to rotate
Expand Down Expand Up @@ -303,6 +308,7 @@ export class RedBlackTree<T> implements Iterable<T> {
}

/**
* @ignore
* Performs a right rotation on the given node
* @private
* @param node The node to rotate
Expand Down Expand Up @@ -330,6 +336,7 @@ export class RedBlackTree<T> implements Iterable<T> {
}

/**
* @ignore
* Fixes the Red-Black Tree properties after insertion
* @private
* @param node The newly inserted node
Expand Down Expand Up @@ -377,6 +384,7 @@ export class RedBlackTree<T> implements Iterable<T> {
}

/**
* @ignore
* Deletes a node from the tree
* @private
* @param node The node to delete
Expand Down Expand Up @@ -417,6 +425,7 @@ export class RedBlackTree<T> implements Iterable<T> {
}

/**
* @ignore
* Fixes the Red-Black Tree properties after deletion
* @private
* @param node The node to start fixing from
Expand Down Expand Up @@ -490,6 +499,7 @@ export class RedBlackTree<T> implements Iterable<T> {
}

/**
* @ignore
* Replaces one subtree with another subtree
* @private
* @param u The root of the subtree to replace
Expand All @@ -509,6 +519,7 @@ export class RedBlackTree<T> implements Iterable<T> {
}

/**
* @ignore
* Finds the node with the minimum value in a subtree
* @private
* @param node The root of the subtree
Expand All @@ -523,6 +534,7 @@ export class RedBlackTree<T> implements Iterable<T> {
}

/**
* @ignore
* Performs an in-order traversal of the tree
* @private
* @param node The root of the subtree to traverse
Expand Down
1 change: 1 addition & 0 deletions src/core/sorted-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ export class SortedMap<K, V> implements Iterable<[K, V]> {
}

/**
* @ignore
* Default comparison function for values
* @private
* @param a First value to compare
Expand Down
5 changes: 5 additions & 0 deletions src/core/trie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class Trie<T> {
}

/**
* @ignore
* Creates a new TrieNode
* @private
*/
Expand All @@ -54,6 +55,7 @@ export class Trie<T> {
}

/**
* @ignore
* Normalizes the key based on case sensitivity setting
* @private
*/
Expand Down Expand Up @@ -209,6 +211,7 @@ export class Trie<T> {
}

/**
* @ignore
* Gets the node at the end of the given word path
* @private
*/
Expand All @@ -228,6 +231,7 @@ export class Trie<T> {
}

/**
* @ignore
* Recursively collects all words under a node
* @private
*/
Expand All @@ -246,6 +250,7 @@ export class Trie<T> {
}

/**
* @ignore
* Recursively collects all entries under a node
* @private
*/
Expand Down