Comparing version 0.2.0 to 0.3.0
# Changelog | ||
## 0.3.0 | ||
* Adding `FibonacciHeap`. | ||
* Fixing bug related to `Heap`. | ||
## 0.2.0 | ||
@@ -4,0 +9,0 @@ |
@@ -53,3 +53,3 @@ # Heap | ||
```js | ||
var heap = new heap(); | ||
var heap = new Heap(); | ||
@@ -74,3 +74,3 @@ heap.push(4); | ||
```js | ||
var heap = new heap(); | ||
var heap = new Heap(); | ||
@@ -77,0 +77,0 @@ heap.push(34); |
@@ -20,3 +20,2 @@ # Trie | ||
* [#.longestPrefix](#longestprefix) | ||
* [#.toObject](#toobject) | ||
@@ -23,0 +22,0 @@ ### #.size |
28
heap.js
@@ -7,27 +7,8 @@ /** | ||
*/ | ||
var comparators = require('./utils/heap-comparators.js'); | ||
/** | ||
* Defaults. | ||
*/ | ||
var DEFAULT_COMPARATOR = function(a, b) { | ||
if (a < b) | ||
return -1; | ||
if (a > b) | ||
return 1; | ||
var DEFAULT_COMPARATOR = comparators.DEFAULT_COMPARATOR, | ||
DEFAULT_REVERSED_COMPARATOR = comparators.DEFAULT_REVERSED_COMPARATOR; | ||
return 0; | ||
}; | ||
/** | ||
* Function used to reverse a comparator. | ||
*/ | ||
function reverseComparator(comparator) { | ||
return function(a, b) { | ||
return comparator(b, a); | ||
}; | ||
} | ||
var DEFAULT_REVERSED_COMPARATOR = reverseComparator(DEFAULT_COMPARATOR); | ||
/** | ||
* Binary Minimum Heap. | ||
@@ -152,2 +133,5 @@ * | ||
Heap.prototype.pop = function() { | ||
if (!this.size) | ||
return undefined; | ||
var item = this.items[0], | ||
@@ -154,0 +138,0 @@ last = this.items.pop(); |
@@ -9,4 +9,6 @@ /** | ||
module.exports = { | ||
Heap: require('./heap.js'), | ||
LinkedList: require('./linked-list.js'), | ||
Stack: require('./stack.js') | ||
Stack: require('./stack.js'), | ||
Trie: require('./trie.js') | ||
}; |
{ | ||
"name": "mnemonist", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Collection of classic data structures for JavaScript.", | ||
@@ -13,2 +13,4 @@ "main": "index.js", | ||
"docs", | ||
"utils", | ||
"fibonacci-heap.js", | ||
"heap.js", | ||
@@ -28,2 +30,3 @@ "index.js", | ||
"heap", | ||
"fibonacci heap", | ||
"stack", | ||
@@ -30,0 +33,0 @@ "queue", |
@@ -22,2 +22,3 @@ [![Build Status](https://travis-ci.org/Yomguithereal/mnemonist.svg)](https://travis-ci.org/Yomguithereal/mnemonist) | ||
* [Fibonacci Heap](docs/fibonacci-heap.md) | ||
* [Heap](docs/heap.md) | ||
@@ -24,0 +25,0 @@ * [Linked List](docs/linked-list.md) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29187
16
834
48