undirected-graph-typed
Advanced tools
Comparing version 1.48.8 to 1.48.9
@@ -40,6 +40,2 @@ /** | ||
* 5. Leaf Nodes: Nodes without children are leaves. | ||
* 6. Internal Nodes: Nodes with at least one child are internal. | ||
* 7. Balanced Trees: The heights of the left and right subtrees of any node differ by no more than one. | ||
* 8. Full Trees: Every node has either 0 or 2 children. | ||
* 9. Complete Trees: All levels are fully filled except possibly the last, filled from left to right. | ||
*/ | ||
@@ -46,0 +42,0 @@ export declare class BinaryTree<K = any, V = any, N extends BinaryTreeNode<K, V, N> = BinaryTreeNode<K, V, BinaryTreeNodeNested<K, V>>, TREE extends BinaryTree<K, V, N, TREE> = BinaryTree<K, V, N, BinaryTreeNested<K, V, N>>> extends IterableEntryBase<K, V | undefined> implements IBinaryTree<K, V, N, TREE> { |
@@ -442,111 +442,1 @@ /** | ||
} | ||
export declare class ObjectDeque<E = number> { | ||
constructor(capacity?: number); | ||
protected _nodes: { | ||
[key: number]: E; | ||
}; | ||
get nodes(): { | ||
[p: number]: E; | ||
}; | ||
protected _capacity: number; | ||
get capacity(): number; | ||
protected _first: number; | ||
get first(): number; | ||
protected _last: number; | ||
get last(): number; | ||
protected _size: number; | ||
get size(): number; | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
*/ | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
* | ||
* The "addFirst" function adds an element to the beginning of an array-like data structure. | ||
* @param {E} element - The `element` parameter represents the element that you want to add to the beginning of the data | ||
* structure. | ||
*/ | ||
addFirst(element: E): void; | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
*/ | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
* | ||
* The addLast function adds an element to the end of an array-like data structure. | ||
* @param {E} element - The `element` parameter represents the element that you want to add to the end of the data structure. | ||
*/ | ||
addLast(element: E): void; | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
*/ | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
* | ||
* The function `pollFirst()` removes and returns the first element in a data structure. | ||
* @returns The element of the first element in the data structure. | ||
*/ | ||
pollFirst(): E | undefined; | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
*/ | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
* | ||
* The `getFirst` function returns the first element in an array-like data structure if it exists. | ||
* @returns The element at the first position of the `_nodes` array. | ||
*/ | ||
getFirst(): E | undefined; | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
*/ | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
* | ||
* The `pollLast()` function removes and returns the last element in a data structure. | ||
* @returns The element that was removed from the data structure. | ||
*/ | ||
pollLast(): E | undefined; | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
*/ | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
* | ||
* The `getLast()` function returns the last element in an array-like data structure. | ||
* @returns The last element in the array "_nodes" is being returned. | ||
*/ | ||
getLast(): E | undefined; | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
*/ | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
* | ||
* The get function returns the element at the specified index in an array-like data structure. | ||
* @param {number} index - The index parameter is a number that represents the position of the element you want to | ||
* retrieve from the array. | ||
* @returns The element at the specified index in the `_nodes` array is being returned. If there is no element at that | ||
* index, `undefined` is returned. | ||
*/ | ||
get(index: number): NonNullable<E> | undefined; | ||
/** | ||
* The function checks if the size of a data structure is less than or equal to zero. | ||
* @returns The method is returning a boolean element indicating whether the size of the object is less than or equal to 0. | ||
*/ | ||
isEmpty(): boolean; | ||
} |
@@ -10,3 +10,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ObjectDeque = exports.Deque = void 0; | ||
exports.Deque = void 0; | ||
const utils_1 = require("../../utils"); | ||
@@ -796,172 +796,1 @@ const base_1 = require("../base"); | ||
exports.Deque = Deque; | ||
// O(1) time complexity of obtaining the element | ||
// O(n) time complexity of adding at the beginning and the end | ||
// todo tested slowest one | ||
class ObjectDeque { | ||
constructor(capacity) { | ||
this._nodes = {}; | ||
this._capacity = Number.MAX_SAFE_INTEGER; | ||
this._first = -1; | ||
this._last = -1; | ||
this._size = 0; | ||
if (capacity !== undefined) | ||
this._capacity = capacity; | ||
} | ||
get nodes() { | ||
return this._nodes; | ||
} | ||
get capacity() { | ||
return this._capacity; | ||
} | ||
get first() { | ||
return this._first; | ||
} | ||
get last() { | ||
return this._last; | ||
} | ||
get size() { | ||
return this._size; | ||
} | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
*/ | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
* | ||
* The "addFirst" function adds an element to the beginning of an array-like data structure. | ||
* @param {E} element - The `element` parameter represents the element that you want to add to the beginning of the data | ||
* structure. | ||
*/ | ||
addFirst(element) { | ||
if (this.size === 0) { | ||
const mid = Math.floor(this.capacity / 2); | ||
this._first = mid; | ||
this._last = mid; | ||
} | ||
else { | ||
this._first--; | ||
} | ||
this.nodes[this.first] = element; | ||
this._size++; | ||
} | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
*/ | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
* | ||
* The addLast function adds an element to the end of an array-like data structure. | ||
* @param {E} element - The `element` parameter represents the element that you want to add to the end of the data structure. | ||
*/ | ||
addLast(element) { | ||
if (this.size === 0) { | ||
const mid = Math.floor(this.capacity / 2); | ||
this._first = mid; | ||
this._last = mid; | ||
} | ||
else { | ||
this._last++; | ||
} | ||
this.nodes[this.last] = element; | ||
this._size++; | ||
} | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
*/ | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
* | ||
* The function `pollFirst()` removes and returns the first element in a data structure. | ||
* @returns The element of the first element in the data structure. | ||
*/ | ||
pollFirst() { | ||
if (!this.size) | ||
return; | ||
const element = this.getFirst(); | ||
delete this.nodes[this.first]; | ||
this._first++; | ||
this._size--; | ||
return element; | ||
} | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
*/ | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
* | ||
* The `getFirst` function returns the first element in an array-like data structure if it exists. | ||
* @returns The element at the first position of the `_nodes` array. | ||
*/ | ||
getFirst() { | ||
if (this.size) | ||
return this.nodes[this.first]; | ||
} | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
*/ | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
* | ||
* The `pollLast()` function removes and returns the last element in a data structure. | ||
* @returns The element that was removed from the data structure. | ||
*/ | ||
pollLast() { | ||
if (!this.size) | ||
return; | ||
const element = this.getLast(); | ||
delete this.nodes[this.last]; | ||
this._last--; | ||
this._size--; | ||
return element; | ||
} | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
*/ | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
* | ||
* The `getLast()` function returns the last element in an array-like data structure. | ||
* @returns The last element in the array "_nodes" is being returned. | ||
*/ | ||
getLast() { | ||
if (this.size) | ||
return this.nodes[this.last]; | ||
} | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
*/ | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
* | ||
* The get function returns the element at the specified index in an array-like data structure. | ||
* @param {number} index - The index parameter is a number that represents the position of the element you want to | ||
* retrieve from the array. | ||
* @returns The element at the specified index in the `_nodes` array is being returned. If there is no element at that | ||
* index, `undefined` is returned. | ||
*/ | ||
get(index) { | ||
return this.nodes[this.first + index] || undefined; | ||
} | ||
/** | ||
* The function checks if the size of a data structure is less than or equal to zero. | ||
* @returns The method is returning a boolean element indicating whether the size of the object is less than or equal to 0. | ||
*/ | ||
isEmpty() { | ||
return this.size <= 0; | ||
} | ||
} | ||
exports.ObjectDeque = ObjectDeque; |
{ | ||
"name": "undirected-graph-typed", | ||
"version": "1.48.8", | ||
"version": "1.48.9", | ||
"description": "Undirected Graph. Javascript & Typescript Data Structure.", | ||
@@ -148,4 +148,4 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"data-structure-typed": "^1.48.8" | ||
"data-structure-typed": "^1.48.9" | ||
} | ||
} |
@@ -852,192 +852,2 @@ /** | ||
} | ||
} | ||
// O(1) time complexity of obtaining the element | ||
// O(n) time complexity of adding at the beginning and the end | ||
// todo tested slowest one | ||
export class ObjectDeque<E = number> { | ||
constructor(capacity?: number) { | ||
if (capacity !== undefined) this._capacity = capacity; | ||
} | ||
protected _nodes: { [key: number]: E } = {}; | ||
get nodes(): { [p: number]: E } { | ||
return this._nodes; | ||
} | ||
protected _capacity = Number.MAX_SAFE_INTEGER; | ||
get capacity(): number { | ||
return this._capacity; | ||
} | ||
protected _first = -1; | ||
get first(): number { | ||
return this._first; | ||
} | ||
protected _last = -1; | ||
get last(): number { | ||
return this._last; | ||
} | ||
protected _size = 0; | ||
get size(): number { | ||
return this._size; | ||
} | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
*/ | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
* | ||
* The "addFirst" function adds an element to the beginning of an array-like data structure. | ||
* @param {E} element - The `element` parameter represents the element that you want to add to the beginning of the data | ||
* structure. | ||
*/ | ||
addFirst(element: E) { | ||
if (this.size === 0) { | ||
const mid = Math.floor(this.capacity / 2); | ||
this._first = mid; | ||
this._last = mid; | ||
} else { | ||
this._first--; | ||
} | ||
this.nodes[this.first] = element; | ||
this._size++; | ||
} | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
*/ | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
* | ||
* The addLast function adds an element to the end of an array-like data structure. | ||
* @param {E} element - The `element` parameter represents the element that you want to add to the end of the data structure. | ||
*/ | ||
addLast(element: E) { | ||
if (this.size === 0) { | ||
const mid = Math.floor(this.capacity / 2); | ||
this._first = mid; | ||
this._last = mid; | ||
} else { | ||
this._last++; | ||
} | ||
this.nodes[this.last] = element; | ||
this._size++; | ||
} | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
*/ | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
* | ||
* The function `pollFirst()` removes and returns the first element in a data structure. | ||
* @returns The element of the first element in the data structure. | ||
*/ | ||
pollFirst() { | ||
if (!this.size) return; | ||
const element = this.getFirst(); | ||
delete this.nodes[this.first]; | ||
this._first++; | ||
this._size--; | ||
return element; | ||
} | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
*/ | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
* | ||
* The `getFirst` function returns the first element in an array-like data structure if it exists. | ||
* @returns The element at the first position of the `_nodes` array. | ||
*/ | ||
getFirst() { | ||
if (this.size) return this.nodes[this.first]; | ||
} | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
*/ | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
* | ||
* The `pollLast()` function removes and returns the last element in a data structure. | ||
* @returns The element that was removed from the data structure. | ||
*/ | ||
pollLast() { | ||
if (!this.size) return; | ||
const element = this.getLast(); | ||
delete this.nodes[this.last]; | ||
this._last--; | ||
this._size--; | ||
return element; | ||
} | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
*/ | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
* | ||
* The `getLast()` function returns the last element in an array-like data structure. | ||
* @returns The last element in the array "_nodes" is being returned. | ||
*/ | ||
getLast() { | ||
if (this.size) return this.nodes[this.last]; | ||
} | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
*/ | ||
/** | ||
* Time Complexity: O(1) | ||
* Space Complexity: O(1) | ||
* | ||
* The get function returns the element at the specified index in an array-like data structure. | ||
* @param {number} index - The index parameter is a number that represents the position of the element you want to | ||
* retrieve from the array. | ||
* @returns The element at the specified index in the `_nodes` array is being returned. If there is no element at that | ||
* index, `undefined` is returned. | ||
*/ | ||
get(index: number) { | ||
return this.nodes[this.first + index] || undefined; | ||
} | ||
/** | ||
* The function checks if the size of a data structure is less than or equal to zero. | ||
* @returns The method is returning a boolean element indicating whether the size of the object is less than or equal to 0. | ||
*/ | ||
isEmpty() { | ||
return this.size <= 0; | ||
} | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1919806
36210
Updateddata-structure-typed@^1.48.9