nlptoolkit-datastructure 1.0.7 → 1.0.9

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 (54) hide show
  1. package/README.md +1 -1
  2. package/dist/CounterHashMap.js +108 -118
  3. package/dist/CounterHashMap.js.map +1 -1
  4. package/dist/LRUCache.js +55 -63
  5. package/dist/LRUCache.js.map +1 -1
  6. package/dist/Queue.d.ts +24 -0
  7. package/dist/Queue.js +57 -40
  8. package/dist/Queue.js.map +1 -1
  9. package/dist/Stack.d.ts +23 -0
  10. package/dist/Stack.js +42 -29
  11. package/dist/Stack.js.map +1 -1
  12. package/dist/heap/Heap.d.ts +53 -0
  13. package/dist/heap/Heap.js +115 -68
  14. package/dist/heap/Heap.js.map +1 -1
  15. package/dist/heap/HeapNode.d.ts +8 -0
  16. package/dist/heap/HeapNode.js +19 -20
  17. package/dist/heap/HeapNode.js.map +1 -1
  18. package/dist/heap/MaxHeap.js +11 -21
  19. package/dist/heap/MaxHeap.js.map +1 -1
  20. package/dist/heap/MinHeap.js +11 -21
  21. package/dist/heap/MinHeap.js.map +1 -1
  22. package/dist/index.d.ts +9 -0
  23. package/dist/index.js +26 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/tree/AvlTree.d.ts +81 -0
  26. package/dist/tree/AvlTree.js +163 -92
  27. package/dist/tree/AvlTree.js.map +1 -1
  28. package/dist/tree/AvlTreeNode.js +11 -20
  29. package/dist/tree/AvlTreeNode.js.map +1 -1
  30. package/dist/tree/BTree.d.ts +35 -0
  31. package/dist/tree/BTree.js +76 -49
  32. package/dist/tree/BTree.js.map +1 -1
  33. package/dist/tree/BTreeNode.d.ts +69 -0
  34. package/dist/tree/BTreeNode.js +168 -104
  35. package/dist/tree/BTreeNode.js.map +1 -1
  36. package/dist/tree/Tree.d.ts +37 -0
  37. package/dist/tree/Tree.js +83 -55
  38. package/dist/tree/Tree.js.map +1 -1
  39. package/dist/tree/TreeNode.js +11 -20
  40. package/dist/tree/TreeNode.js.map +1 -1
  41. package/package.json +5 -7
  42. package/source/Queue.ts +24 -0
  43. package/source/Stack.ts +23 -0
  44. package/source/heap/Heap.ts +53 -0
  45. package/source/heap/HeapNode.ts +8 -0
  46. package/source/heap/MaxHeap.ts +0 -1
  47. package/source/index.ts +9 -0
  48. package/source/tree/AvlTree.ts +81 -0
  49. package/source/tree/BTree.ts +35 -0
  50. package/source/tree/BTreeNode.ts +69 -0
  51. package/source/tree/Tree.ts +37 -0
  52. package/tsconfig.json +4 -5
  53. package/index.js +0 -9
  54. package/source/tsconfig.json +0 -13
package/dist/Stack.js CHANGED
@@ -1,35 +1,48 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Stack = void 0;
4
+ /**
5
+ * Stack is a list data structure consisting of many elements. There are two types of operations defined for the
6
+ * elements of the stack: Adding an element to the stack (push) and removing an element from the stack (pop). In a
7
+ * stack, to be popped element is always the last pushed element. Also, when an element is pushed on to the stack, it
8
+ * is placed on top of the stack (at the end of the list).
9
+ * @param T Type of the data stored in the stack node.
10
+ */
11
+ class Stack {
12
+ list = [];
13
+ constructor() {
5
14
  }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports"], factory);
15
+ /**
16
+ * When we push an element on top of the stack, we only need to increase the field top by 1 and place the new
17
+ * element on this new position. If the stack is full before this push operation, we can not push.
18
+ * @param item Item to insert.
19
+ */
20
+ push(item) {
21
+ this.list.push(item);
8
22
  }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Stack = void 0;
13
- class Stack {
14
- constructor() {
15
- this.list = [];
23
+ /**
24
+ * When we remove an element from the stack (the function also returns that removed element), we need to be careful
25
+ * if the stack was empty or not. If the stack is not empty, the topmost element of the stack is returned and the
26
+ * field top is decreased by 1. If the stack is empty, the function will return null.
27
+ * @return The removed element
28
+ */
29
+ pop() {
30
+ let item = this.list.pop();
31
+ if (item == undefined) {
32
+ return null;
16
33
  }
17
- push(item) {
18
- this.list.push(item);
19
- }
20
- pop() {
21
- let item = this.list.pop();
22
- if (item == undefined) {
23
- return null;
24
- }
25
- else {
26
- return item;
27
- }
28
- }
29
- isEmpty() {
30
- return this.list.length == 0;
34
+ else {
35
+ return item;
31
36
  }
32
37
  }
33
- exports.Stack = Stack;
34
- });
38
+ /**
39
+ * The function checks whether an array-implemented stack is empty or not. The function returns true if the stack is
40
+ * empty, false otherwise.
41
+ * @return True if the stack is empty, false otherwise.
42
+ */
43
+ isEmpty() {
44
+ return this.list.length == 0;
45
+ }
46
+ }
47
+ exports.Stack = Stack;
35
48
  //# sourceMappingURL=Stack.js.map
package/dist/Stack.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Stack.js","sourceRoot":"","sources":["../source/Stack.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,MAAa,KAAK;QAId;YAFQ,SAAI,GAAc,EAAE,CAAA;QAG5B,CAAC;QAEM,IAAI,CAAC,IAAO;YACf,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC;QAEM,GAAG;YACN,IAAI,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAA;YAC1B,IAAI,IAAI,IAAI,SAAS,EAAC;gBAClB,OAAO,IAAI,CAAA;aACd;iBAAM;gBACH,OAAO,IAAI,CAAA;aACd;QACL,CAAC;QAEM,OAAO;YACV,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAA;QAChC,CAAC;KAGJ;IAzBD,sBAyBC"}
1
+ {"version":3,"file":"Stack.js","sourceRoot":"","sources":["../source/Stack.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,MAAa,KAAK;IAEN,IAAI,GAAc,EAAE,CAAA;IAE5B;IACA,CAAC;IAED;;;;OAIG;IACI,IAAI,CAAC,IAAO;QACf,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAED;;;;;OAKG;IACI,GAAG;QACN,IAAI,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAA;QAC1B,IAAI,IAAI,IAAI,SAAS,EAAC,CAAC;YACnB,OAAO,IAAI,CAAA;QACf,CAAC;aAAM,CAAC;YACJ,OAAO,IAAI,CAAA;QACf,CAAC;IACL,CAAC;IAED;;;;OAIG;IACI,OAAO;QACV,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAA;IAChC,CAAC;CAGJ;AAzCD,sBAyCC"}
@@ -1,14 +1,67 @@
1
+ /**
2
+ * <p>The heap data structure is a binary tree structure consisting of N elements. It shows the basic properties of the
3
+ * binary tree data structure. The heap has a root node and each node of it has at most two child nodes
4
+ * (left and right). The root node of the tree is shown at the top, and its branches grow not to up but to down manner.
5
+ * </p>
6
+ *
7
+ * <p>In a heap, if the maximum element is in the root node and all nodes are smaller than its descendants, then this heap
8
+ * is called max-heap, if the minimum element is in the root node and all nodes are larger than its descendants, then
9
+ * this heap is called min-heap.</p>
10
+ * @param T Type of the data stored in the heap node.
11
+ */
1
12
  export declare class Heap<T> {
2
13
  private readonly array;
3
14
  protected comparator: (item1: T, item2: T) => number;
4
15
  private count;
5
16
  private n;
17
+ /**
18
+ * Constructor of the heap. According to the comparator, the heap could be min or max heap.
19
+ * @param N Maximum number of elements in the heap.
20
+ * @param comparator Comparator function to compare two elements.
21
+ */
6
22
  constructor(N: number, comparator: (item1: T, item2: T) => number);
7
23
  compare(data1: T, data2: T): number;
24
+ /**
25
+ * Checks if the heap is empty or not.
26
+ * @return True if the heap is empty, false otherwise.
27
+ */
8
28
  isEmpty(): boolean;
29
+ /**
30
+ * Swaps two heap nodes in the heap given their indexes.
31
+ * @param index1 Index of the first node to swap.
32
+ * @param index2 Index of the second node to swap.
33
+ */
9
34
  private swapNode;
35
+ /**
36
+ * The function percolates down from a node of the tree to restore the max-heap property. Left or right children are
37
+ * checked, if one of them is larger than the current element of the heap, the iteration continues. The iteration is,
38
+ * determining the largest one of the node's children and switching that node's value with the current node's value.
39
+ * We need to check if current node's left and right children exist or not. These checks are done with for the left
40
+ * child and with for the right child.
41
+ * @param no Index of the starting node to restore the max-heap property.
42
+ */
10
43
  protected percolateDown(no: number): void;
44
+ /**
45
+ * The function percolates up from a node of the tree to restore the max-heap property. As long as the max-heap
46
+ * property is corrupted, the parent and its child switch their values. We need to pay attention that, the
47
+ * calculated index of the parent must be a valid number. In other words, while going upper levels,we need to see
48
+ * that we can not go up if we are at the root of the tree.
49
+ * @param no Index of the starting node to restore the max-heap property.
50
+ */
11
51
  protected percolateUp(no: number): void;
52
+ /**
53
+ * The function will return the first element, therefore the first element is stored in the variable, and the first
54
+ * element of the heap is set to the last element of the heap. After that, in order to restore the max-heap
55
+ * property, we percolate down the tree using the function. As a last step, the number of element in the heap is
56
+ * decremented by one.
57
+ * @return The first element
58
+ */
12
59
  delete(): T;
60
+ /**
61
+ * The insertion of a new element to the heap, proceeds from the leaf nodes to the root node. First the new element
62
+ * is added to the end of the heap, then as long as the max-heap property is corrupted, the new element switches
63
+ * place with its parent.
64
+ * @param data New element to be inserted.
65
+ */
13
66
  insert(data: T): void;
14
67
  }
package/dist/heap/Heap.js CHANGED
@@ -1,77 +1,124 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Heap = void 0;
4
+ const HeapNode_1 = require("./HeapNode");
5
+ /**
6
+ * <p>The heap data structure is a binary tree structure consisting of N elements. It shows the basic properties of the
7
+ * binary tree data structure. The heap has a root node and each node of it has at most two child nodes
8
+ * (left and right). The root node of the tree is shown at the top, and its branches grow not to up but to down manner.
9
+ * </p>
10
+ *
11
+ * <p>In a heap, if the maximum element is in the root node and all nodes are smaller than its descendants, then this heap
12
+ * is called max-heap, if the minimum element is in the root node and all nodes are larger than its descendants, then
13
+ * this heap is called min-heap.</p>
14
+ * @param T Type of the data stored in the heap node.
15
+ */
16
+ class Heap {
17
+ array;
18
+ comparator;
19
+ count;
20
+ n;
21
+ /**
22
+ * Constructor of the heap. According to the comparator, the heap could be min or max heap.
23
+ * @param N Maximum number of elements in the heap.
24
+ * @param comparator Comparator function to compare two elements.
25
+ */
26
+ constructor(N, comparator) {
27
+ this.comparator = comparator;
28
+ this.array = new Array();
29
+ this.count = 0;
30
+ this.n = N;
31
+ for (let i = 0; i < N; i++) {
32
+ this.array.push();
33
+ }
5
34
  }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./HeapNode"], factory);
35
+ compare(data1, data2) {
36
+ return 0;
8
37
  }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Heap = void 0;
13
- const HeapNode_1 = require("./HeapNode");
14
- class Heap {
15
- constructor(N, comparator) {
16
- this.comparator = comparator;
17
- this.array = new Array();
18
- this.count = 0;
19
- this.n = N;
20
- for (let i = 0; i < N; i++) {
21
- this.array.push();
22
- }
23
- }
24
- compare(data1, data2) {
25
- return 0;
26
- }
27
- isEmpty() {
28
- return this.count == 0;
29
- }
30
- swapNode(index1, index2) {
31
- let tmp = this.array[index1];
32
- this.array[index1] = this.array[index2];
33
- this.array[index2] = tmp;
34
- }
35
- percolateDown(no) {
36
- let left = 2 * no + 1;
37
- let right = 2 * no + 2;
38
- while ((left < this.count && this.compare(this.array[no].getData(), this.array[left].getData()) < 0) ||
39
- (right < this.count && this.compare(this.array[no].getData(), this.array[right].getData()) < 0)) {
40
- if (right >= this.count || this.compare(this.array[left].getData(), this.array[right].getData()) > 0) {
41
- this.swapNode(no, left);
42
- no = left;
43
- }
44
- else {
45
- this.swapNode(no, right);
46
- no = right;
47
- }
48
- left = 2 * no + 1;
49
- right = 2 * no + 2;
38
+ /**
39
+ * Checks if the heap is empty or not.
40
+ * @return True if the heap is empty, false otherwise.
41
+ */
42
+ isEmpty() {
43
+ return this.count == 0;
44
+ }
45
+ /**
46
+ * Swaps two heap nodes in the heap given their indexes.
47
+ * @param index1 Index of the first node to swap.
48
+ * @param index2 Index of the second node to swap.
49
+ */
50
+ swapNode(index1, index2) {
51
+ let tmp = this.array[index1];
52
+ this.array[index1] = this.array[index2];
53
+ this.array[index2] = tmp;
54
+ }
55
+ /**
56
+ * The function percolates down from a node of the tree to restore the max-heap property. Left or right children are
57
+ * checked, if one of them is larger than the current element of the heap, the iteration continues. The iteration is,
58
+ * determining the largest one of the node's children and switching that node's value with the current node's value.
59
+ * We need to check if current node's left and right children exist or not. These checks are done with for the left
60
+ * child and with for the right child.
61
+ * @param no Index of the starting node to restore the max-heap property.
62
+ */
63
+ percolateDown(no) {
64
+ let left = 2 * no + 1;
65
+ let right = 2 * no + 2;
66
+ while ((left < this.count && this.compare(this.array[no].getData(), this.array[left].getData()) < 0) ||
67
+ (right < this.count && this.compare(this.array[no].getData(), this.array[right].getData()) < 0)) {
68
+ if (right >= this.count || this.compare(this.array[left].getData(), this.array[right].getData()) > 0) {
69
+ this.swapNode(no, left);
70
+ no = left;
50
71
  }
51
- }
52
- percolateUp(no) {
53
- let parent = Math.floor((no - 1) / 2);
54
- while (parent >= 0 && this.compare(this.array[parent].getData(), this.array[no].getData()) < 0) {
55
- this.swapNode(parent, no);
56
- no = parent;
57
- parent = Math.floor((no - 1) / 2);
72
+ else {
73
+ this.swapNode(no, right);
74
+ no = right;
58
75
  }
76
+ left = 2 * no + 1;
77
+ right = 2 * no + 2;
59
78
  }
60
- delete() {
61
- let tmp = this.array[0];
62
- this.array[0] = this.array[this.count - 1];
63
- this.percolateDown(0);
64
- this.count = this.count - 1;
65
- return tmp.getData();
79
+ }
80
+ /**
81
+ * The function percolates up from a node of the tree to restore the max-heap property. As long as the max-heap
82
+ * property is corrupted, the parent and its child switch their values. We need to pay attention that, the
83
+ * calculated index of the parent must be a valid number. In other words, while going upper levels,we need to see
84
+ * that we can not go up if we are at the root of the tree.
85
+ * @param no Index of the starting node to restore the max-heap property.
86
+ */
87
+ percolateUp(no) {
88
+ let parent = Math.floor((no - 1) / 2);
89
+ while (parent >= 0 && this.compare(this.array[parent].getData(), this.array[no].getData()) < 0) {
90
+ this.swapNode(parent, no);
91
+ no = parent;
92
+ parent = Math.floor((no - 1) / 2);
66
93
  }
67
- insert(data) {
68
- if (this.count < this.n) {
69
- this.count = this.count + 1;
70
- }
71
- this.array[this.count - 1] = new HeapNode_1.HeapNode(data);
72
- this.percolateUp(this.count - 1);
94
+ }
95
+ /**
96
+ * The function will return the first element, therefore the first element is stored in the variable, and the first
97
+ * element of the heap is set to the last element of the heap. After that, in order to restore the max-heap
98
+ * property, we percolate down the tree using the function. As a last step, the number of element in the heap is
99
+ * decremented by one.
100
+ * @return The first element
101
+ */
102
+ delete() {
103
+ let tmp = this.array[0];
104
+ this.array[0] = this.array[this.count - 1];
105
+ this.percolateDown(0);
106
+ this.count = this.count - 1;
107
+ return tmp.getData();
108
+ }
109
+ /**
110
+ * The insertion of a new element to the heap, proceeds from the leaf nodes to the root node. First the new element
111
+ * is added to the end of the heap, then as long as the max-heap property is corrupted, the new element switches
112
+ * place with its parent.
113
+ * @param data New element to be inserted.
114
+ */
115
+ insert(data) {
116
+ if (this.count < this.n) {
117
+ this.count = this.count + 1;
73
118
  }
119
+ this.array[this.count - 1] = new HeapNode_1.HeapNode(data);
120
+ this.percolateUp(this.count - 1);
74
121
  }
75
- exports.Heap = Heap;
76
- });
122
+ }
123
+ exports.Heap = Heap;
77
124
  //# sourceMappingURL=Heap.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Heap.js","sourceRoot":"","sources":["../../source/heap/Heap.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,yCAAoC;IAEpC,MAAa,IAAI;QAOb,YAAY,CAAS,EAAE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AC,CAAA;QACrB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,CAAA;QAC3B,OAAO,GAAG,CAAC,OAAO,EAAE,CAAA;IACxB,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,IAAO;QACjB,IAAI,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC;YACtB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,CAAA;QAC/B,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,mBAAQ,CAAI,IAAI,CAAC,CAAA;QAClD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAA;IACpC,CAAC;CAEJ;AAnHD,oBAmHC"}
@@ -1,5 +1,13 @@
1
1
  export declare class HeapNode<T> {
2
2
  data: T;
3
+ /**
4
+ * Constructor of HeapNode.
5
+ * @param data Data to be stored in the heap node.
6
+ */
3
7
  constructor(data: T);
8
+ /**
9
+ * Mutator of the data field
10
+ * @return Data
11
+ */
4
12
  getData(): T;
5
13
  }
@@ -1,23 +1,22 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HeapNode = void 0;
4
+ class HeapNode {
5
+ data;
6
+ /**
7
+ * Constructor of HeapNode.
8
+ * @param data Data to be stored in the heap node.
9
+ */
10
+ constructor(data) {
11
+ this.data = data;
5
12
  }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports"], factory);
13
+ /**
14
+ * Mutator of the data field
15
+ * @return Data
16
+ */
17
+ getData() {
18
+ return this.data;
8
19
  }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.HeapNode = void 0;
13
- class HeapNode {
14
- constructor(data) {
15
- this.data = data;
16
- }
17
- getData() {
18
- return this.data;
19
- }
20
- }
21
- exports.HeapNode = HeapNode;
22
- });
20
+ }
21
+ exports.HeapNode = HeapNode;
23
22
  //# sourceMappingURL=HeapNode.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"HeapNode.js","sourceRoot":"","sources":["../../source/heap/HeapNode.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,MAAa,QAAQ;QAIjB,YAAY,IAAO;YACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QACpB,CAAC;QAEM,OAAO;YACV,OAAO,IAAI,CAAC,IAAI,CAAA;QACpB,CAAC;KAEJ;IAZD,4BAYC"}
1
+ {"version":3,"file":"HeapNode.js","sourceRoot":"","sources":["../../source/heap/HeapNode.ts"],"names":[],"mappings":";;;AAAA,MAAa,QAAQ;IAEjB,IAAI,CAAI;IAER;;;OAGG;IACH,YAAY,IAAO;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IACpB,CAAC;IAED;;;OAGG;IACI,OAAO;QACV,OAAO,IAAI,CAAC,IAAI,CAAA;IACpB,CAAC;CAEJ;AApBD,4BAoBC"}
@@ -1,24 +1,14 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MaxHeap = void 0;
4
+ const Heap_1 = require("./Heap");
5
+ class MaxHeap extends Heap_1.Heap {
6
+ constructor(N, comparator) {
7
+ super(N, comparator);
5
8
  }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./Heap"], factory);
9
+ compare(data1, data2) {
10
+ return this.comparator(data1, data2);
8
11
  }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.MaxHeap = void 0;
13
- const Heap_1 = require("./Heap");
14
- class MaxHeap extends Heap_1.Heap {
15
- constructor(N, comparator) {
16
- super(N, comparator);
17
- }
18
- compare(data1, data2) {
19
- return this.comparator(data1, data2);
20
- }
21
- }
22
- exports.MaxHeap = MaxHeap;
23
- });
12
+ }
13
+ exports.MaxHeap = MaxHeap;
24
14
  //# sourceMappingURL=MaxHeap.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MaxHeap.js","sourceRoot":"","sources":["../../source/heap/MaxHeap.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,iCAA4B;IAG5B,MAAa,OAAW,SAAQ,WAAO;QAEnC,YAAY,CAAS,EAAE,UAA0C;YAC7D,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAA;QACxB,CAAC;QAED,OAAO,CAAC,KAAQ,EAAE,KAAQ;YACtB,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;QACxC,CAAC;KAEJ;IAVD,0BAUC"}
1
+ {"version":3,"file":"MaxHeap.js","sourceRoot":"","sources":["../../source/heap/MaxHeap.ts"],"names":[],"mappings":";;;AAAA,iCAA4B;AAE5B,MAAa,OAAW,SAAQ,WAAO;IAEnC,YAAY,CAAS,EAAE,UAA0C;QAC7D,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAA;IACxB,CAAC;IAED,OAAO,CAAC,KAAQ,EAAE,KAAQ;QACtB,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;IACxC,CAAC;CAEJ;AAVD,0BAUC"}
@@ -1,24 +1,14 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MinHeap = void 0;
4
+ const Heap_1 = require("./Heap");
5
+ class MinHeap extends Heap_1.Heap {
6
+ constructor(N, comparator) {
7
+ super(N, comparator);
5
8
  }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./Heap"], factory);
9
+ compare(data1, data2) {
10
+ return -this.comparator(data1, data2);
8
11
  }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.MinHeap = void 0;
13
- const Heap_1 = require("./Heap");
14
- class MinHeap extends Heap_1.Heap {
15
- constructor(N, comparator) {
16
- super(N, comparator);
17
- }
18
- compare(data1, data2) {
19
- return -this.comparator(data1, data2);
20
- }
21
- }
22
- exports.MinHeap = MinHeap;
23
- });
12
+ }
13
+ exports.MinHeap = MinHeap;
24
14
  //# sourceMappingURL=MinHeap.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MinHeap.js","sourceRoot":"","sources":["../../source/heap/MinHeap.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,iCAA4B;IAE5B,MAAa,OAAW,SAAQ,WAAO;QAEnC,YAAY,CAAS,EAAE,UAA0C;YAC7D,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAA;QACxB,CAAC;QAED,OAAO,CAAC,KAAQ,EAAE,KAAQ;YACtB,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;QACzC,CAAC;KAEJ;IAVD,0BAUC"}
1
+ {"version":3,"file":"MinHeap.js","sourceRoot":"","sources":["../../source/heap/MinHeap.ts"],"names":[],"mappings":";;;AAAA,iCAA4B;AAE5B,MAAa,OAAW,SAAQ,WAAO;IAEnC,YAAY,CAAS,EAAE,UAA0C;QAC7D,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAA;IACxB,CAAC;IAED,OAAO,CAAC,KAAQ,EAAE,KAAQ;QACtB,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;IACzC,CAAC;CAEJ;AAVD,0BAUC"}
@@ -0,0 +1,9 @@
1
+ export * from "./CounterHashMap";
2
+ export * from "./LRUCache";
3
+ export * from "./Stack";
4
+ export * from "./tree/BTree";
5
+ export * from "./tree/BTreeNode";
6
+ export * from "./tree/AvlTree";
7
+ export * from "./tree/AvlTreeNode";
8
+ export * from "./tree/Tree";
9
+ export * from "./tree/TreeNode";
package/dist/index.js ADDED
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./CounterHashMap"), exports);
18
+ __exportStar(require("./LRUCache"), exports);
19
+ __exportStar(require("./Stack"), exports);
20
+ __exportStar(require("./tree/BTree"), exports);
21
+ __exportStar(require("./tree/BTreeNode"), exports);
22
+ __exportStar(require("./tree/AvlTree"), exports);
23
+ __exportStar(require("./tree/AvlTreeNode"), exports);
24
+ __exportStar(require("./tree/Tree"), exports);
25
+ __exportStar(require("./tree/TreeNode"), exports);
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAgC;AAChC,6CAA0B;AAC1B,0CAAuB;AACvB,+CAA4B;AAC5B,mDAAgC;AAChC,iDAA8B;AAC9B,qDAAkC;AAClC,8CAA2B;AAC3B,kDAA+B"}