bst-typed 1.49.1 → 1.49.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/data-structures/base/iterable-base.d.ts +11 -0
  2. package/dist/data-structures/base/iterable-base.js +21 -0
  3. package/dist/data-structures/graph/abstract-graph.d.ts +7 -7
  4. package/dist/data-structures/graph/abstract-graph.js +43 -12
  5. package/dist/data-structures/graph/directed-graph.d.ts +2 -2
  6. package/dist/data-structures/graph/directed-graph.js +2 -2
  7. package/dist/data-structures/graph/undirected-graph.d.ts +1 -1
  8. package/dist/data-structures/graph/undirected-graph.js +1 -1
  9. package/dist/data-structures/hash/hash-map.d.ts +9 -9
  10. package/dist/data-structures/hash/hash-map.js +16 -15
  11. package/dist/data-structures/heap/heap.d.ts +6 -35
  12. package/dist/data-structures/heap/heap.js +10 -42
  13. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +99 -105
  14. package/dist/data-structures/linked-list/doubly-linked-list.js +143 -146
  15. package/dist/data-structures/linked-list/singly-linked-list.d.ts +16 -21
  16. package/dist/data-structures/linked-list/singly-linked-list.js +42 -42
  17. package/dist/data-structures/linked-list/skip-linked-list.d.ts +25 -25
  18. package/dist/data-structures/linked-list/skip-linked-list.js +36 -36
  19. package/dist/data-structures/queue/deque.d.ts +70 -75
  20. package/dist/data-structures/queue/deque.js +100 -110
  21. package/dist/data-structures/queue/queue.d.ts +37 -38
  22. package/dist/data-structures/queue/queue.js +46 -49
  23. package/dist/data-structures/stack/stack.d.ts +2 -3
  24. package/dist/data-structures/stack/stack.js +2 -5
  25. package/dist/data-structures/trie/trie.d.ts +1 -2
  26. package/dist/data-structures/trie/trie.js +2 -5
  27. package/package.json +2 -2
  28. package/src/data-structures/base/iterable-base.ts +24 -0
  29. package/src/data-structures/graph/abstract-graph.ts +55 -14
  30. package/src/data-structures/graph/directed-graph.ts +3 -2
  31. package/src/data-structures/graph/undirected-graph.ts +1 -1
  32. package/src/data-structures/hash/hash-map.ts +27 -28
  33. package/src/data-structures/heap/heap.ts +19 -57
  34. package/src/data-structures/linked-list/doubly-linked-list.ts +157 -161
  35. package/src/data-structures/linked-list/singly-linked-list.ts +49 -49
  36. package/src/data-structures/linked-list/skip-linked-list.ts +40 -40
  37. package/src/data-structures/queue/deque.ts +122 -135
  38. package/src/data-structures/queue/queue.ts +54 -58
  39. package/src/data-structures/stack/stack.ts +4 -8
  40. package/src/data-structures/trie/trie.ts +5 -9
@@ -138,7 +138,7 @@ export class Trie extends IterableElementBase<string> {
138
138
  * @param{string} word - The word to delete.
139
139
  * @returns {boolean} True if the word was successfully removed.
140
140
  */
141
- delete(word: string) {
141
+ delete(word: string): boolean {
142
142
  word = this._caseProcess(word);
143
143
  let isDeleted = false;
144
144
  const dfs = (cur: TrieNode, i: number): boolean => {
@@ -184,7 +184,7 @@ export class Trie extends IterableElementBase<string> {
184
184
  * Space Complexity: O(1) - Constant space.
185
185
  *
186
186
  */
187
- getHeight() {
187
+ getHeight(): number {
188
188
  const beginRoot = this.root;
189
189
  let maxDepth = 0;
190
190
  if (beginRoot) {
@@ -371,12 +371,12 @@ export class Trie extends IterableElementBase<string> {
371
371
  * specific object as the context for the `predicate` function. If `thisArg` is provided, it will be
372
372
  * @returns The `filter` method is returning an array of strings (`string[]`).
373
373
  */
374
- filter(predicate: ElementCallback<string, boolean>, thisArg?: any): string[] {
375
- const results: string[] = [];
374
+ filter(predicate: ElementCallback<string, boolean>, thisArg?: any): Trie {
375
+ const results: Trie = new Trie();
376
376
  let index = 0;
377
377
  for (const word of this) {
378
378
  if (predicate.call(thisArg, word, index, this)) {
379
- results.push(word);
379
+ results.add(word);
380
380
  }
381
381
  index++;
382
382
  }
@@ -411,10 +411,6 @@ export class Trie extends IterableElementBase<string> {
411
411
  return newTrie;
412
412
  }
413
413
 
414
- print() {
415
- console.log([...this]);
416
- }
417
-
418
414
  protected* _getIterator(): IterableIterator<string> {
419
415
  function* _dfs(node: TrieNode, path: string): IterableIterator<string> {
420
416
  if (node.isEnd) {