Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tyriar/fibonacci-heap

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tyriar/fibonacci-heap - npm Package Compare versions

Comparing version 1.0.3 to 1.0.5

2

package.json
{
"name": "@tyriar/fibonacci-heap",
"version": "1.0.3",
"version": "1.0.5",
"description": "An implementation of the Fibonacci heap data structure",

@@ -5,0 +5,0 @@ "scripts": {

@@ -9,2 +9,9 @@ # js-fibonacci-heap [![NPM version](https://img.shields.io/npm/v/@tyriar/fibonacci-heap.svg?style=flat)](https://www.npmjs.org/package/@tyriar/fibonacci-heap)

## Features
- 100% test coverage
- Supports all common heap operations
- Store keys with optional associated values
- Optional custom compare function that can utilize both key and value to give full control over the order of the data
## Install

@@ -19,14 +26,42 @@

```javascript
var FibonacciHeap = require("@tyriar/fibonacci-heap");
// Import npm module
var FibonacciHeap = require('@tyriar/fibonacci-heap';
// Construct FibonacciHeap
var heap = new FibonacciHeap();
// Insert keys only
heap.insert(3);
heap.insert(7);
heap.insert(8);
heap.insert(1);
heap.insert(2);
// Insert keys and values
heap.insert(8, {foo: 'bar'});
heap.insert(1, {foo: 'baz'});
// Extract all nodes in order
while (!heap.isEmpty()) {
console.log(heap.extractMinimum());
var node = heap.extractMinimum();
console.log('key: ' + node.key + ', value: ' + node.value);
}
// > key: 1, value: [object Object]
// > key: 3, value: undefined
// > key: 7, value: undefined
// > key: 8, value: [object Object]
// Construct custom compare FibonacciHeap
heap = new FibonacciHeap(function (a, b) {
return (a.key + a.value).localeCompare(b.key + b.value);
});
heap.insert('2', 'B');
heap.insert('1', 'a');
heap.insert('1', 'A');
heap.insert('2', 'b');
// Extract all nodes in order
while (!heap.isEmpty()) {
var node = heap.extractMinimum();
console.log('key: ' + node.key + ', value: ' + node.value);
}
// > key: 1, value: a
// > key: 1, value: A
// > key: 2, value: b
// > key: 2, value: B
```

@@ -33,0 +68,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc