File tree 3 files changed +13
-10
lines changed 3 files changed +13
-10
lines changed Original file line number Diff line number Diff line change 1
- [ js-heapq] ( https://data-structures-and-algorithms.github.io/heapq )
1
+ :vertical_traffic_light :
2
+ [ @data-structure/heapq ] ( https://data-structures-and-algorithms.github.io/heapq )
2
3
==
3
4
4
5
Python's heap and priority queue library for JavaScript. Parents are
8
9
9
10
10
11
``` js
11
- let {
12
+ import {
12
13
heapify ,
13
14
heappop ,
14
15
heappush ,
17
18
merge ,
18
19
nlargest ,
19
20
nsmallest ,
20
- } = heapq ;
21
+ } from ' @data-structure/ heapq' ;
21
22
```
22
23
23
24
[ ![ License] ( https://img.shields.io/github/license/data-structures-and-algorithms/heapq.svg )] ( https://raw.githubusercontent.com/data-structures-and-algorithms/heapq/main/LICENSE )
35
36
[ ![ Documentation] ( https://data-structures-and-algorithms.github.io/heapq/badge.svg )] ( https://data-structures-and-algorithms.github.io/heapq/source.html )
36
37
[ ![ Package size] ( https://img.shields.io/bundlephobia/minzip/@data-structures-and-algorithms/heapq )] ( https://bundlephobia.com/result?p=@data-structures-and-algorithms/heapq )
37
38
38
- ## References
39
+ ## : scroll : References
39
40
40
41
- [ Python's heapq library] ( https://docs.python.org/3.6/library/heapq.html ) .
Original file line number Diff line number Diff line change @@ -6,11 +6,13 @@ See Python's docs:
6
6
## Changes w.r.t. Python's API
7
7
8
8
``` js
9
- let array = [ 2 , 1 , 3 ] ;
10
- let heap = heapq .heapify ( compare .increasing , array ) ;
9
+ import {heapify , heappop } from ' @data-structure/heapq' ;
10
+ import {increasing } from ' @total-order/primitive' ;
11
+ let array = [2 , 1 , 3 ];
12
+ let heap = heapify (increasing, array);
11
13
array[0 ] ; // 1
12
- heapq . heappop ( heap ) ; // 1
13
- heapq . heappop ( heap ) ; // 2
14
- heapq . heappop ( heap ) ; // 3
14
+ heappop ( heap ) ; // 1
15
+ heappop ( heap ) ; // 2
16
+ heappop ( heap ) ; // 3
15
17
array .length ; // 0
16
18
```
Original file line number Diff line number Diff line change 1
1
{
2
- "name" : " @data-structures-and-algorithms /heapq" ,
2
+ "name" : " @data-structure /heapq" ,
3
3
"description" : " Python's heap and priority queue library for JavaScript" ,
4
4
"version" : " 3.1.0" ,
5
5
"license" : " AGPL-3.0" ,
You can’t perform that action at this time.
0 commit comments