heap-typed 1.19.7 → 1.20.0
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.
- package/README.md +33 -17
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -21,7 +21,11 @@ npm i heap-typed
|
|
|
21
21
|
```bash
|
|
22
22
|
yarn add heap-typed
|
|
23
23
|
```
|
|
24
|
-
|
|
24
|
+
### methods
|
|
25
|
+
Min Heap
|
|
26
|
+

|
|
27
|
+
Max Heap
|
|
28
|
+

|
|
25
29
|
### snippet
|
|
26
30
|
|
|
27
31
|
#### TS
|
|
@@ -32,14 +36,20 @@ yarn add heap-typed
|
|
|
32
36
|
|
|
33
37
|
const minNumHeap = new MinHeap<number>();
|
|
34
38
|
minNumHeap.add(1).add(6).add(2).add(0).add(5).add(9);
|
|
35
|
-
minNumHeap.
|
|
36
|
-
minNumHeap.
|
|
37
|
-
minNumHeap.
|
|
38
|
-
minNumHeap.
|
|
39
|
-
minNumHeap.
|
|
40
|
-
minNumHeap.
|
|
41
|
-
minNumHeap.
|
|
42
|
-
minNumHeap.toArray()
|
|
39
|
+
minNumHeap.has(1) // true
|
|
40
|
+
minNumHeap.has(2) // true
|
|
41
|
+
minNumHeap.poll() // 0
|
|
42
|
+
minNumHeap.poll() // 1
|
|
43
|
+
minNumHeap.peek() // 2
|
|
44
|
+
minNumHeap.has(1); // false
|
|
45
|
+
minNumHeap.has(2); // true
|
|
46
|
+
const arrFromHeap = minNumHeap.toArray();
|
|
47
|
+
arrFromHeap.length // 4
|
|
48
|
+
arrFromHeap[0] // 2
|
|
49
|
+
arrFromHeap[1] // 5
|
|
50
|
+
arrFromHeap[2] // 9
|
|
51
|
+
arrFromHeap[3] // 6
|
|
52
|
+
minNumHeap.sort() // [2, 5, 6, 9]
|
|
43
53
|
|
|
44
54
|
|
|
45
55
|
const maxHeap = new MaxHeap<{ keyA: string }>();
|
|
@@ -84,14 +94,20 @@ yarn add heap-typed
|
|
|
84
94
|
|
|
85
95
|
const minNumHeap = new MinHeap();
|
|
86
96
|
minNumHeap.add(1).add(6).add(2).add(0).add(5).add(9);
|
|
87
|
-
minNumHeap.
|
|
88
|
-
minNumHeap.
|
|
89
|
-
minNumHeap.
|
|
90
|
-
minNumHeap.
|
|
91
|
-
minNumHeap.
|
|
92
|
-
minNumHeap.
|
|
93
|
-
minNumHeap.
|
|
94
|
-
minNumHeap.toArray()
|
|
97
|
+
minNumHeap.has(1) // true
|
|
98
|
+
minNumHeap.has(2) // true
|
|
99
|
+
minNumHeap.poll() // 0
|
|
100
|
+
minNumHeap.poll() // 1
|
|
101
|
+
minNumHeap.peek() // 2
|
|
102
|
+
minNumHeap.has(1); // false
|
|
103
|
+
minNumHeap.has(2); // true
|
|
104
|
+
const arrFromHeap = minNumHeap.toArray();
|
|
105
|
+
arrFromHeap.length // 4
|
|
106
|
+
arrFromHeap[0] // 2
|
|
107
|
+
arrFromHeap[1] // 5
|
|
108
|
+
arrFromHeap[2] // 9
|
|
109
|
+
arrFromHeap[3] // 6
|
|
110
|
+
minNumHeap.sort() // [2, 5, 6, 9]
|
|
95
111
|
|
|
96
112
|
|
|
97
113
|
const maxHeap = new MaxHeap();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "heap-typed",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.0",
|
|
4
4
|
"description": "Heap. Javascript & Typescript Data Structure.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"typescript": "^4.9.5"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"data-structure-typed": "^1.
|
|
60
|
+
"data-structure-typed": "^1.20.0",
|
|
61
61
|
"zod": "^3.22.2"
|
|
62
62
|
}
|
|
63
63
|
}
|