1
- [ js-collections ] ( http://aureooms.github.io/js-collections )
1
+ [ js-heapq ] ( http://aureooms.github.io/js-heapq )
2
2
==
3
3
4
- Collections library for JavaScript. Parent is
4
+ Python's heap and priority queue library for JavaScript. Parent is
5
5
[ js-data-structures] ( https://github.com/aureooms/js-data-structures ) .
6
6
7
- JavaScript version of
8
- [ Python's collections library] ( https://docs.python.org/3.6/library/collections.html )
9
- together with
10
- [ Python's heapq library] ( https://docs.python.org/3.6/library/heapq.html )
11
- and
12
- [ Python's bisect library] ( https://docs.python.org/3.6/library/bisect.html ) .
13
7
14
8
``` js
15
9
let {
16
- heapq , bisect ,
17
- namedtuple ,
18
- deque ,
19
- set ,
20
- dict , defaultdict , ordereddict , counter , chainmap
21
- } = collections ;
10
+ heapify ,
11
+ heappop ,
12
+ heappush ,
13
+ heappushpop ,
14
+ heapreplace ,
15
+ merge ,
16
+ nlargest ,
17
+ nsmallest ,
18
+ } = heapq ;
22
19
```
23
20
24
- [ ![ NPM license] ( http://img.shields.io/npm/l/aureooms-js-collections .svg?style=flat )] ( https://raw.githubusercontent.com/aureooms/js-collections /master/LICENSE )
25
- [ ![ NPM version] ( http://img.shields.io/npm/v/aureooms-js-collections .svg?style=flat )] ( https://www.npmjs.org/package/aureooms-js-collections )
26
- [ ![ Build Status] ( http://img.shields.io/travis/aureooms/js-collections .svg?style=flat )] ( https://travis-ci.org/aureooms/js-collections )
27
- [ ![ Coverage Status] ( http://img.shields.io/coveralls/aureooms/js-collections .svg?style=flat )] ( https://coveralls.io/r/aureooms/js-collections )
28
- [ ![ Dependencies Status] ( http://img.shields.io/david/aureooms/js-collections .svg?style=flat )] ( https://david-dm.org/aureooms/js-collections #info=dependencies )
29
- [ ![ devDependencies Status] ( http://img.shields.io/david/dev/aureooms/js-collections .svg?style=flat )] ( https://david-dm.org/aureooms/js-collections #info=devDependencies )
30
- [ ![ Code Climate] ( http://img.shields.io/codeclimate/github/aureooms/js-collections .svg?style=flat )] ( https://codeclimate.com/github/aureooms/js-collections )
31
- [ ![ NPM downloads per month] ( http://img.shields.io/npm/dm/aureooms-js-collections .svg?style=flat )] ( https://www.npmjs.org/package/aureooms-js-collections )
32
- [ ![ GitHub issues] ( http://img.shields.io/github/issues/aureooms/js-collections .svg?style=flat )] ( https://github.com/aureooms/js-collections /issues )
33
- [ ![ Documentation] ( https://aureooms.github.io/js-collections /badge.svg )] ( https://aureooms.github.io/js-collections /source.html )
21
+ [ ![ NPM license] ( http://img.shields.io/npm/l/aureooms-js-heapq .svg?style=flat )] ( https://raw.githubusercontent.com/aureooms/js-heapq /master/LICENSE )
22
+ [ ![ NPM version] ( http://img.shields.io/npm/v/aureooms-js-heapq .svg?style=flat )] ( https://www.npmjs.org/package/aureooms-js-heapq )
23
+ [ ![ Build Status] ( http://img.shields.io/travis/aureooms/js-heapq .svg?style=flat )] ( https://travis-ci.org/aureooms/js-heapq )
24
+ [ ![ Coverage Status] ( http://img.shields.io/coveralls/aureooms/js-heapq .svg?style=flat )] ( https://coveralls.io/r/aureooms/js-heapq )
25
+ [ ![ Dependencies Status] ( http://img.shields.io/david/aureooms/js-heapq .svg?style=flat )] ( https://david-dm.org/aureooms/js-heapq #info=dependencies )
26
+ [ ![ devDependencies Status] ( http://img.shields.io/david/dev/aureooms/js-heapq .svg?style=flat )] ( https://david-dm.org/aureooms/js-heapq #info=devDependencies )
27
+ [ ![ Code Climate] ( http://img.shields.io/codeclimate/github/aureooms/js-heapq .svg?style=flat )] ( https://codeclimate.com/github/aureooms/js-heapq )
28
+ [ ![ NPM downloads per month] ( http://img.shields.io/npm/dm/aureooms-js-heapq .svg?style=flat )] ( https://www.npmjs.org/package/aureooms-js-heapq )
29
+ [ ![ GitHub issues] ( http://img.shields.io/github/issues/aureooms/js-heapq .svg?style=flat )] ( https://github.com/aureooms/js-heapq /issues )
30
+ [ ![ Documentation] ( https://aureooms.github.io/js-heapq /badge.svg )] ( https://aureooms.github.io/js-heapq /source.html )
34
31
35
- ### Some changes w.r.t. Python's API
36
-
37
- #### ` heapq `
32
+ ## Changes w.r.t. Python's API
38
33
39
34
``` js
40
35
let array = [ 2 , 1 , 3 ] ;
@@ -45,31 +40,7 @@ heapq.heappop( heap ) ; // 2
45
40
heapq .heappop ( heap ) ; // 3
46
41
array .length ; // 0
47
42
```
48
- #### ` set `
49
43
50
- ##### ` set( iterable = null ) -> this `
51
- ##### ` set.inclusion( A , B ) -> {-1,0,1} `
52
- ##### ` set.prototype[Symbol.iterator]( ) -> iterable `
53
- ##### ` set.prototype.keys( ) -> iterable `
54
- ##### ` set.prototype.len( ) -> integer `
55
- ##### ` set.prototype.has( key ) -> boolean `
56
- ##### ` set.prototype.isdisjoint( other ) -> boolean `
57
- ##### ` set.prototype.isequal( other ) -> boolean `
58
- ##### ` set.prototype.issubset( other ) -> boolean `
59
- ##### ` set.prototype.ispropersubset( other ) -> boolean `
60
- ##### ` set.prototype.issuperset( other ) -> boolean `
61
- ##### ` set.prototype.ispropersuperset( other ) -> boolean `
62
- ##### ` set.prototype.union( ...others ) -> set `
63
- ##### ` set.prototype.intersection( ...others ) -> set `
64
- ##### ` set.prototype.difference( ...others ) -> set `
65
- ##### ` set.prototype.symmetric_difference( other ) -> set `
66
- ##### ` set.prototype.copy( ) -> set `
67
- ##### ` set.prototype.update( ...others ) -> this `
68
- ##### ` set.prototype.intersection_update( ...others ) -> this `
69
- ##### ` set.prototype.difference_update( ...others ) -> this `
70
- ##### ` set.prototype.symmetric_difference_update( other ) -> this `
71
- ##### ` set.prototype.add( key ) -> this `
72
- ##### ` set.prototype.remove( key ) -> this `
73
- ##### ` set.prototype.discard( key ) -> this `
74
- ##### ` set.prototype.pop( ) -> key `
75
- ##### ` set.prototype.clear( ) -> this `
44
+ ## References
45
+
46
+ - [ Python's heapq library] ( https://docs.python.org/3.6/library/heapq.html ) .
0 commit comments