Skip to content

Commit

Permalink
build
Browse files Browse the repository at this point in the history
  • Loading branch information
201flaviosilva committed May 16, 2024
1 parent 556c4de commit a21a7f1
Show file tree
Hide file tree
Showing 12 changed files with 1,097 additions and 701 deletions.
1,270 changes: 725 additions & 545 deletions dist/utilidades.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/utilidades.umd.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/getVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import pck from "../package.json";
* Returns the current version of the library
*
* @example
* getVersion(); // "1.3.3"
* getVersion(); // "1.4.0"
*
* @returns {String}
*/
Expand Down
92 changes: 56 additions & 36 deletions types/DataStructures/BinarySearchTree.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
/**
* @class Node
* @class
* @name BSTNode
* @classdesc Create a node for BinarySearchTree
*
* @param {number} value - The value to be stored in the node
*
* @property {number} value - The value stored in the node
* @property {BSTNode|null} left - The left node in the tree
* @property {BSTNode|null} right - The right node in the tree
*/
export class Node {
constructor(value: any);
value: any;
left: any;
right: any;
parent: any;
}
/**
* @class BinarySearchTree
* @class
* @name BinarySearchTree
* @classdesc
* Starts a Binary Search Tree algorithm
*
Expand All @@ -25,26 +32,15 @@ export class Node {
* bst.add(0);
* bst.delete(0);
*
* @constructor
* @param {number[]|number} [value] - The value to start the tree
*
* @property {BSTNode|null} root - The root node of the tree
* @property {number} count - The number of nodes in the tree
*/
export class BinarySearchTree {
constructor(startValue: any);
root: Node;
constructor(value: any);
root: any;
count: number;
/**
* Returns the number of nodes in the tree
*
* @example
* const bst = new BinarySearchTree();
* bst.add(1);
* bst.add(0);
* bst.add(2);
* bst.size(); // 3
*
* @returns {number} Number of nodes
* @memberof BinarySearchTree
*/
size(): number;
/**
* Add a new value to the Tree
*
Expand All @@ -54,48 +50,72 @@ export class BinarySearchTree {
* bst.add(100);
*
* @param {number} value - a number to add
* @memberof BinarySearchTree
*/
add(value: number): void;
add(value: number): this;
/**
* Finds the smallest value in the tree.
*
* - If a value is passed it will look for the smallest value from that branch;
* - If no value is passed, it will start from the root;
*
* @param {number} value - the value to start searching
* @returns {number|undefined} smaller value
* @memberof BinarySearchTree
* @param {number|undefined} [value] - the value to start searching
* @returns {number|undefined|null} smaller value
*/
smaller(value: number): number | undefined;
smaller(value?: number | undefined): number | undefined | null;
/**
* Finds the largest value in the tree.
*
* - If a value is passed it will look for the largest value from that branch;
* - If no value is passed, it will start from the root;
*
* @param {number} value - the value to start searching
* @returns {number|undefined} largest value
* @memberof BinarySearchTree
* @returns {number|undefined|null} largest value
*/
larger(value: number): number | undefined;
larger(value: number): number | undefined | null;
/**
* - Returns `false` if the number does not exist or if there is an error
* - If the number exists, return its node
* - If the number exists, return its node/true
*
* @param {number} value - the value to find
* @returns {Node} if the value is in the Tree
* @memberof BinarySearchTree
* @param {boolean} [returnNode=true] - if the node should be returned
* @returns {BSTNode|null} if the value is in the Tree
*/
search(value: number): Node;
search(value: number, returnNode?: boolean): BSTNode | null;
/**
* Delete the node with the given value
*
* @param {number} value - the value to delete
* @returns {boolean} if the node was deleted
* @memberof BinarySearchTree
* @param {boolean} [returnNode=false] - if the node should be returned
* @returns {BSTNode|BinarySearchTree} if the value is in the Tree
*/
delete(value: number, returnNode?: boolean): BSTNode | BinarySearchTree;
/**
* Returns a string representation of the tree
*
* @returns {string} the string representation
*/
toString(): string;
/**
* Inserts a new node into the tree
*
* Note 1: This is a recursive function
* Note 2: This function is used in the add method
*
* @param {BSTNode} node - the node to insert
* @param {BSTNode} newNode - the new node
*
* @private
*/
private _insertNode;
/**
* This function finds the parent of the given node
*
* @param {BSTNode} node - the node to find the parent
* @returns {BSTNode|null} the parent of the given node
*
* @private
*/
delete(value: number): boolean;
private _findParent;
}
/**
*
Expand Down
99 changes: 44 additions & 55 deletions types/DataStructures/DoublyLinkedList.d.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
/**
* @class
* @name DoublyLinkedList
* @classdesc
* Represents a doubly linked list data structure.
*
* @memberof DataStructures
* @see https://en.wikipedia.org/wiki/Doubly_linked_list
*
* @example
* new DoublyLinkedList();
* new DoublyLinkedList("Beep");
* new DoublyLinkedList([10,20,30]);
*
* @param {Array|*} value - The value to initialize the list with (optional).
*
* @property {DLLNode} head - The first node in the list
* @property {DLLNode} tail - The last node in the list
* @property {Number} size - The number of nodes in the list
*/
export class DoublyLinkedList {
/**
* Creates a new DoublyLinkedList instance.
*
* @example
* new DoublyLinkedList();
* new DoublyLinkedList("Beep");
* new DoublyLinkedList([10,20,30]);
*
* @param {Array|*} value - The value to initialize the list with (optional).
*/
constructor(value: any[] | any);
constructor(value: any);
head: any;
tail: any;
size: number;
Expand All @@ -26,9 +30,6 @@ export class DoublyLinkedList {
* dll.print(); // 10,20,30
*
* @returns {DoublyLinkedList} The current DoublyLinkedList instance.
*
* @memberof DoublyLinkedList
* @method print
*/
print(): DoublyLinkedList;
/**
Expand All @@ -40,9 +41,6 @@ export class DoublyLinkedList {
* dll.toArray(); // []
*
* @returns {DoublyLinkedList} The current DoublyLinkedList instance.
*
* @memberof DoublyLinkedList
* @method clear
*/
clear(): DoublyLinkedList;
/**
Expand All @@ -54,12 +52,9 @@ export class DoublyLinkedList {
*
* @param {Number} index - The index of the value to retrieve.
* @param {Boolean} returnNode - Whether to return the Node or the value.
* @returns {Number|Node} The value at the specified index, or the Node if returnNode is true.
*
* @memberof DoublyLinkedList
* @method get
* @returns {Number|DLLNode} The value at the specified index, or the Node if returnNode is true.
*/
get(index: number, returnNode?: boolean): number | Node;
get(index: number, returnNode?: boolean): number | DLLNode;
/**
* Sets the value at the specified index in the linked list.
*
Expand All @@ -70,9 +65,6 @@ export class DoublyLinkedList {
* @param {Number} index - The index of the value to set.
* @param {Number} value - The new value to set.
* @returns {Boolean} True if the value was set successfully, false otherwise.
*
* @memberof DoublyLinkedList
* @method set
*/
set(index: number, value: number): boolean;
/**
Expand All @@ -84,9 +76,6 @@ export class DoublyLinkedList {
*
* @param {Number} value - The value to add.
* @returns {DoublyLinkedList} The current DoublyLinkedList instance.
*
* @memberof DoublyLinkedList
* @method unshift
*/
unshift(value: number): DoublyLinkedList;
/**
Expand All @@ -98,9 +87,6 @@ export class DoublyLinkedList {
*
* @param {Number} value - The value to add.
* @returns {DoublyLinkedList} The current DoublyLinkedList instance.
*
* @memberof DoublyLinkedList
* @method push
*/
push(value: number): DoublyLinkedList;
/**
Expand All @@ -113,9 +99,6 @@ export class DoublyLinkedList {
* @param {Number} index - The index to insert the value at.
* @param {Number} value - The value to insert.
* @returns {DoublyLinkedList} The current DoublyLinkedList instance.
*
* @memberof DoublyLinkedList
* @method insert
*/
insert(index: number, value: number): DoublyLinkedList;
/**
Expand All @@ -126,9 +109,6 @@ export class DoublyLinkedList {
* dll.shift(); // 20,30
*
* @returns {Number} The value that was removed.
*
* @memberof DoublyLinkedList
* @method shift
*/
shift(): number;
/**
Expand All @@ -139,9 +119,6 @@ export class DoublyLinkedList {
* dll.pop(); // 10,20
*
* @returns {Number} The value that was removed.
*
* @memberof DoublyLinkedList
* @method pop
*/
pop(): number;
/**
Expand All @@ -153,13 +130,28 @@ export class DoublyLinkedList {
*
* @param {Number} index - The index of the value to remove.
* @returns {Number} The value that was removed.
*
* @memberof DoublyLinkedList
* @method remove
*/
remove(index: number): number;
reverse(): void;
sort(): void;
/**
* Reverses the linked list.
*
* @example
* const dll = new DoublyLinkedList([10,20,30]);
* dll.reverse(); // 30,20,10
*
* @returns {DoublyLinkedList} The current DoublyLinkedList instance.
*/
reverse(): DoublyLinkedList;
/**
* Sorts the linked list in ascending order.
*
* @example
* const dll = new DoublyLinkedList([50,20,40,10,30]);
* dll.sort(); // 10,20,30,40,50
*
* @returns {DoublyLinkedList} The current DoublyLinkedList instance.
*/
sort(): DoublyLinkedList;
/**
* Returns an array representation of the linked list.
*
Expand All @@ -168,23 +160,20 @@ export class DoublyLinkedList {
* dll.toArray(); // [10,20,30]
*
* @returns {Array} The array representation of the linked list.
*
* @memberof DoublyLinkedList
* @method toArray
*/
toArray(): any[];
}
/**
* @class DLLNode
* @class
* @name DLLNode
* @classdesc Represents a node in a doubly linked list.
*
* @memberof DataStructures
* @param {*} [value] - The value to be stored in the node.
*
* @property {*} value - The value stored in the node
* @property {DLLNode|null} next - The next node in the list
*/
export class Node {
/**
* Creates a new Node instance.
* @param {*} value - The value to be stored in the node.
*/
constructor(value: any);
value: any;
next: any;
Expand Down
Loading

0 comments on commit a21a7f1

Please sign in to comment.