File tree Expand file tree Collapse file tree 3 files changed +13
-10
lines changed Expand file tree Collapse file tree 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 )
23==
34
45Python's heap and priority queue library for JavaScript. Parents are
89
910
1011``` js
11- let {
12+ import {
1213 heapify ,
1314 heappop ,
1415 heappush ,
1718 merge ,
1819 nlargest ,
1920 nsmallest ,
20- } = heapq ;
21+ } from ' @data-structure/ heapq' ;
2122```
2223
2324[ ![ License] ( https://img.shields.io/github/license/data-structures-and-algorithms/heapq.svg )] ( https://raw.githubusercontent.com/data-structures-and-algorithms/heapq/main/LICENSE )
3536[ ![ Documentation] ( https://data-structures-and-algorithms.github.io/heapq/badge.svg )] ( https://data-structures-and-algorithms.github.io/heapq/source.html )
3637[ ![ Package size] ( https://img.shields.io/bundlephobia/minzip/@data-structures-and-algorithms/heapq )] ( https://bundlephobia.com/result?p=@data-structures-and-algorithms/heapq )
3738
38- ## References
39+ ## : scroll : References
3940
4041 - [ 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:
66## Changes w.r.t. Python's API
77
88``` 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);
1113array[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
1517array .length ; // 0
1618```
Original file line number Diff line number Diff line change 11{
2- "name" : " @data-structures-and-algorithms /heapq" ,
2+ "name" : " @data-structure /heapq" ,
33 "description" : " Python's heap and priority queue library for JavaScript" ,
44 "version" : " 3.1.0" ,
55 "license" : " AGPL-3.0" ,
You can’t perform that action at this time.
0 commit comments