From 62b1608155ec14cf6e4edd60b04fe2131b4a6ec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Ooms?= Date: Wed, 18 Jan 2017 19:43:21 +0100 Subject: [PATCH 1/3] up deps + es6 modules --- .codeclimate.yml | 7 +- .gitignore | 32 +- .groc.json | 7 - .travis.yml | 18 +- README.md | 151 +--- bower.json | 21 - component.json | 11 - doc/css/style.css | 52 ++ doc/manual/example.md | 57 ++ doc/manual/installation.md | 13 + doc/manual/overview.md | 0 doc/manual/usage.md | 14 + doc/scripts/header.js | 34 + esdoc.json | 37 + inch.json | 5 - js/dist/binomial-heap.js | 891 ---------------------- js/dist/binomial-heap.js.map | 1 - js/dist/binomial-heap.min.js | 2 - js/index.js | 15 - js/src/LazyNode.js | 9 - lib/BinomialHeap.js | 477 ++++++++++++ lib/BinomialTree.js | 42 + lib/BinomialTreeWithParent.js | 50 ++ lib/LazyBinomialHeap.js | 257 +++++++ lib/LazyNode.js | 12 + lib/LazyStack.js | 60 ++ lib/index.js | 48 ++ package.json | 96 ++- pkg.json | 18 - {js/src => src}/BinomialHeap.js | 6 +- {js/src => src}/BinomialTree.js | 6 +- {js/src => src}/BinomialTreeWithParent.js | 6 +- {js/src => src}/LazyBinomialHeap.js | 7 +- src/LazyNode.js | 7 + js/src/LazyList.js => src/LazyStack.js | 8 +- src/index.js | 24 + test/js/index.js | 10 - test/js/src/all.js | 42 - test/src/spec.js | 50 ++ 39 files changed, 1329 insertions(+), 1274 deletions(-) delete mode 100644 .groc.json delete mode 100644 bower.json delete mode 100644 component.json create mode 100644 doc/css/style.css create mode 100644 doc/manual/example.md create mode 100644 doc/manual/installation.md create mode 100644 doc/manual/overview.md create mode 100644 doc/manual/usage.md create mode 100644 doc/scripts/header.js create mode 100644 esdoc.json delete mode 100644 inch.json delete mode 100644 js/dist/binomial-heap.js delete mode 100644 js/dist/binomial-heap.js.map delete mode 100644 js/dist/binomial-heap.min.js delete mode 100644 js/index.js delete mode 100644 js/src/LazyNode.js create mode 100644 lib/BinomialHeap.js create mode 100644 lib/BinomialTree.js create mode 100644 lib/BinomialTreeWithParent.js create mode 100644 lib/LazyBinomialHeap.js create mode 100644 lib/LazyNode.js create mode 100644 lib/LazyStack.js create mode 100644 lib/index.js delete mode 100644 pkg.json rename {js/src => src}/BinomialHeap.js (99%) rename {js/src => src}/BinomialTree.js (89%) rename {js/src => src}/BinomialTreeWithParent.js (88%) rename {js/src => src}/LazyBinomialHeap.js (97%) create mode 100644 src/LazyNode.js rename js/src/LazyList.js => src/LazyStack.js (91%) create mode 100644 src/index.js delete mode 100644 test/js/index.js delete mode 100644 test/js/src/all.js create mode 100644 test/src/spec.js diff --git a/.codeclimate.yml b/.codeclimate.yml index 0672c33..554bdae 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -1,7 +1,6 @@ languages: JavaScript: true exclude_paths: -- "js/dist/*.js" -- "js/dist/**/*.js" -- "test/*.js" -- "test/**/*.js" +- "doc/**" +- "lib/**" +- "test/**" diff --git a/.gitignore b/.gitignore index dcb4ccc..be10dca 100644 --- a/.gitignore +++ b/.gitignore @@ -1,28 +1,10 @@ -# Logs -logs -*.log - -# Runtime data -pids -*.pid -*.seed - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Compiled binary addons (http://nodejs.org/api/addons.html) -build/Release - # Dependency directory -# Deployed apps should consider commenting this line out: -# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git node_modules +jspm_packages + +# Coverage directory used by nyc +coverage +.nyc_output -# groc -doc +# Documentation +gh-pages diff --git a/.groc.json b/.groc.json deleted file mode 100644 index 56e8333..0000000 --- a/.groc.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "glob": [ - "js/src/**/*.js", - "README.md" - ], - "github": true -} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 9a0746b..bd60bd8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,15 @@ language: node_js + node_js: - - "iojs" - - "0.12" - - "0.11" - - "0.10" + - node + install: - - npm -d install + - npm install + script: - - npm test + - npm run cover + after_success: - - ./node_modules/.bin/coveralls < coverage/lcov.info || true - - ./node_modules/.bin/codeclimate < coverage/lcov.info || true + - bash <(curl -s https://codecov.io/bash) || true + - coveralls < coverage/lcov.info || true + - codeclimate-test-reporter < coverage/lcov.info || true diff --git a/README.md b/README.md index f92a5b7..4b0a22e 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ [js-binomial-heap](http://aureooms.github.io/js-binomial-heap) == -Binomial heap code bricks in JavaScript. Parent is -[aureooms/js-heap](https://github.com/aureooms/js-heap). +Binomial heap data structures for JavaScript. +Parent is [aureooms/js-heap](https://github.com/aureooms/js-heap). ```js // @@ -18,7 +18,6 @@ Binomial heap code bricks in JavaScript. Parent is [![NPM license](http://img.shields.io/npm/l/aureooms-js-binomial-heap.svg?style=flat)](https://raw.githubusercontent.com/aureooms/js-binomial-heap/master/LICENSE) [![NPM version](http://img.shields.io/npm/v/aureooms-js-binomial-heap.svg?style=flat)](https://www.npmjs.org/package/aureooms-js-binomial-heap) -[![Bower version](http://img.shields.io/bower/v/aureooms-js-binomial-heap.svg?style=flat)](http://bower.io/search/?q=aureooms-js-binomial-heap) [![Build Status](http://img.shields.io/travis/aureooms/js-binomial-heap.svg?style=flat)](https://travis-ci.org/aureooms/js-binomial-heap) [![Coverage Status](http://img.shields.io/coveralls/aureooms/js-binomial-heap.svg?style=flat)](https://coveralls.io/r/aureooms/js-binomial-heap) [![Dependencies Status](http://img.shields.io/david/aureooms/js-binomial-heap.svg?style=flat)](https://david-dm.org/aureooms/js-binomial-heap#info=dependencies) @@ -26,152 +25,8 @@ Binomial heap code bricks in JavaScript. Parent is [![Code Climate](http://img.shields.io/codeclimate/github/aureooms/js-binomial-heap.svg?style=flat)](https://codeclimate.com/github/aureooms/js-binomial-heap) [![NPM downloads per month](http://img.shields.io/npm/dm/aureooms-js-binomial-heap.svg?style=flat)](https://www.npmjs.org/package/aureooms-js-binomial-heap) [![GitHub issues](http://img.shields.io/github/issues/aureooms/js-binomial-heap.svg?style=flat)](https://github.com/aureooms/js-binomial-heap/issues) -[![Inline docs](http://inch-ci.org/github/aureooms/js-binomial-heap.svg?branch=master&style=shields)](http://inch-ci.org/github/aureooms/js-binomial-heap) - -Can be managed through [jspm](https://github.com/jspm/jspm-cli), -[duo](https://github.com/duojs/duo), -[component](https://github.com/componentjs/component), -[bower](https://github.com/bower/bower), -[ender](https://github.com/ender-js/Ender), -[jam](https://github.com/caolan/jam), -[spm](https://github.com/spmjs/spm), -and [npm](https://github.com/npm/npm). - -## Description - -This package contains binomial heap implementations. - - -## Install - -### jspm -```terminal -jspm install github:aureooms/js-binomial-heap -# or -jspm install npm:aureooms-js-binomial-heap -``` -### duo -No install step needed for duo! - -### component -```terminal -component install aureooms/js-binomial-heap -``` - -### bower -```terminal -bower install aureooms-js-binomial-heap -``` - -### ender -```terminal -ender add aureooms-js-binomial-heap -``` - -### jam -```terminal -jam install aureooms-js-binomial-heap -``` - -### spm -```terminal -spm install aureooms-js-binomial-heap --save -``` - -### npm -```terminal -npm install aureooms-js-binomial-heap --save -``` - -## Require -### jspm -```js -let binomialheap = require( "github:aureooms/js-binomial-heap" ) ; -// or -import binomialheap from 'aureooms-js-binomial-heap' ; -``` -### duo -```js -let binomialheap = require( "aureooms/js-binomial-heap" ) ; -``` - -### component, ender, spm, npm -```js -let binomialheap = require( "aureooms-js-binomial-heap" ) ; -``` - -### bower -The script tag exposes the global variable `binomialheap`. -```html - -``` -Alternatively, you can use any tool mentioned [here](http://bower.io/docs/tools/). - -### jam -```js -require( [ "aureooms-js-binomial-heap" ] , function ( binomialheap ) { ... } ) ; -``` - -## Use - -```js -// can choose between 3 different implementations -// -// - BinomialHeap( BinomialTreeWithParent ) -// # head -> value -// # headreference -> reference -// # pop -> value -// # popreference -> reference -// # push( value ) -> reference -// # pushreference( reference ) -// # merge( other ) -// # update( reference , value ) -// # decreasekey( reference , value ) -// # increasekey( reference , value ) -// # delete( reference ) -// -// - BinomialHeap( BinomialTree ) -// # head -> value -// # pop -> value -// # push( value ) -// # merge( other ) -// -// - LazyBinomialHeap( BinomialTree ) -// # pop -> value -// # push( value ) -// # merge( other ) - -let compare = require( "aureooms-js-compare" ) ; - -let Heap = binomialheap. ... ( binomialheap. ... ) ; - -let a = new Heap( compare.increasing ) ; -let b = new Heap( compare.increasing ) ; - -a.push( 5 ) ; -a.push( 1 ) ; -a.push( 4 ) ; -b.push( 3 ) ; -b.push( 2 ) ; - -a.length ; // 3 -b.length ; // 2 - -a.merge( b ) ; -delete b ; - -a.length ; // 5 - -a.pop( ) ; // 1 -a.pop( ) ; // 2 -a.pop( ) ; // 3 -a.pop( ) ; // 4 -a.pop( ) ; // 5 - -a.length ; // 0 -``` +[![Documentation](https://aureooms.github.io/js-binomial-heap/badge.svg)](https://aureooms.github.io/js-binomial-heap/source.html) ## Reference - http://www.cs.princeton.edu/~wayne/cs423/lectures/heaps-4up.pdf - diff --git a/bower.json b/bower.json deleted file mode 100644 index d16e282..0000000 --- a/bower.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "homepage": "http://aureooms.github.io/js-binomial-heap/", - "name": "aureooms-js-binomial-heap", - "license": "AGPL-3.0", - "description": "Binomial heap code bricks for JavaScript", - "version": "10.0.1", - "main": "js/dist/binomial-heap.js", - "ignore": [ - "js/index.js", - "js/src", - "test", - "pkg.json", - "package.json", - ".groc.json", - ".travis.yml", - ".gitignore", - "README.md", - "inch.json", - ".codeclimate.yml" - ] -} \ No newline at end of file diff --git a/component.json b/component.json deleted file mode 100644 index 925f815..0000000 --- a/component.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "aureooms-js-binomial-heap", - "repo": "aureooms/js-binomial-heap", - "scripts": [ - "js/dist/binomial-heap.js" - ], - "version": "10.0.1", - "description": "Binomial heap code bricks for JavaScript", - "main": "js/dist/binomial-heap.js", - "license": "AGPL-3.0" -} \ No newline at end of file diff --git a/doc/css/style.css b/doc/css/style.css new file mode 100644 index 0000000..ed56934 --- /dev/null +++ b/doc/css/style.css @@ -0,0 +1,52 @@ +h1, +h2, +.navigation, +.layout-container > header, +footer +{ + border: none; +} + +.project-name { + color: #FC913A; + font-weight: bold; +} + +.layout-container > header > a.repo-url-github { + font-size: inherit; + display: inline; + background: none; + vertical-align: inherit; +} + +.search-box img { + display: none; +} + +.search-box::before{ + content: "search"; +} + +.search-input-edge { + height: 0px; +} + +.search-result { + width: 300px; + margin-left: 42px; + box-shadow: 1px 1px 13px rgba(0,0,0,0.2); +} + +.search-input { + visibility: visible; +} + +.search-result li.search-separator { + text-transform: capitalize; + background-color: #ccc; +} + +span[data-ice="signature"] > span { + /*font-weight: bold;*/ + font-style: italic; +} diff --git a/doc/manual/example.md b/doc/manual/example.md new file mode 100644 index 0000000..741944e --- /dev/null +++ b/doc/manual/example.md @@ -0,0 +1,57 @@ + +```js +// can choose between 3 different implementations +// +// - BinomialHeap( BinomialTreeWithParent ) +// # head -> value +// # headreference -> reference +// # pop -> value +// # popreference -> reference +// # push( value ) -> reference +// # pushreference( reference ) +// # merge( other ) +// # update( reference , value ) +// # decreasekey( reference , value ) +// # increasekey( reference , value ) +// # delete( reference ) +// +// - BinomialHeap( BinomialTree ) +// # head -> value +// # pop -> value +// # push( value ) +// # merge( other ) +// +// - LazyBinomialHeap( BinomialTree ) +// # pop -> value +// # push( value ) +// # merge( other ) + +let compare = require( "aureooms-js-compare" ) ; + +let Heap = binomialheap. ... ( binomialheap. ... ) ; + +let a = new Heap( compare.increasing ) ; +let b = new Heap( compare.increasing ) ; + +a.push( 5 ) ; +a.push( 1 ) ; +a.push( 4 ) ; +b.push( 3 ) ; +b.push( 2 ) ; + +a.length ; // 3 +b.length ; // 2 + +a.merge( b ) ; +delete b ; + +a.length ; // 5 + +a.pop( ) ; // 1 +a.pop( ) ; // 2 +a.pop( ) ; // 3 +a.pop( ) ; // 4 +a.pop( ) ; // 5 + +a.length ; // 0 +``` diff --git a/doc/manual/installation.md b/doc/manual/installation.md new file mode 100644 index 0000000..cb0d8df --- /dev/null +++ b/doc/manual/installation.md @@ -0,0 +1,13 @@ +Can be managed using +[jspm](http://jspm.io) +or [npm](https://github.com/npm/npm). + +### jspm +```terminal +jspm install npm:aureooms-js-binomial-heap +``` + +### npm +```terminal +npm install aureooms-js-binomial-heap --save +``` diff --git a/doc/manual/overview.md b/doc/manual/overview.md new file mode 100644 index 0000000..e69de29 diff --git a/doc/manual/usage.md b/doc/manual/usage.md new file mode 100644 index 0000000..0bf3345 --- /dev/null +++ b/doc/manual/usage.md @@ -0,0 +1,14 @@ +The code needs a ES2015+ polyfill to work, for example +[babel-polyfill](https://babeljs.io/docs/usage/polyfill). +```js +require( 'babel-polyfill' ) ; +// or +import 'babel-polyfill' ; +``` + +Then +```js +const binomialheap = require( 'aureooms-js-binomial-heap' ) ; +// or +import binomialheap from 'aureooms-js-binomial-heap' ; +``` diff --git a/doc/scripts/header.js b/doc/scripts/header.js new file mode 100644 index 0000000..df005d7 --- /dev/null +++ b/doc/scripts/header.js @@ -0,0 +1,34 @@ +var domReady = function(callback) { + var state = document.readyState ; + if ( state === 'interactive' || state === 'complete' ) { + callback() ; + } + else { + document.addEventListener('DOMContentLoaded', callback); + } +} ; + + +domReady(function(){ + + var projectname = document.createElement('a'); + projectname.classList.add('project-name'); + projectname.text = 'aureooms/js-binomial-heap'; + projectname.href = './index.html' ; + + var header = document.getElementsByTagName('header')[0] ; + header.insertBefore(projectname,header.firstChild); + + var testlink = document.querySelector('header > a[data-ice="testLink"]') ; + testlink.href = 'https://coveralls.io/github/aureooms/js-binomial-heap' ; + testlink.target = '_BLANK' ; + + var searchBox = document.querySelector('.search-box'); + var input = document.querySelector('.search-input'); + + // active search box when focus on searchBox. + input.addEventListener('focus', function(){ + searchBox.classList.add('active'); + }); + +}); diff --git a/esdoc.json b/esdoc.json new file mode 100644 index 0000000..f2645d6 --- /dev/null +++ b/esdoc.json @@ -0,0 +1,37 @@ +{ + "source": "./src", + "destination": "./gh-pages", + "access": [ + "public", + "protected", + "private" + ], + "debug": false, + "index": "./README.md", + "package": "./package.json", + "title": "aureooms/js-binomial-heap", + "test": { + "type": "ava", + "source": "./test/src" + }, + "manual": { + "overview": [ + "./doc/manual/overview.md" + ], + "installation": [ + "./doc/manual/installation.md" + ], + "usage": [ + "./doc/manual/usage.md" + ], + "example": [ + "./doc/manual/example.md" + ] + }, + "styles": [ + "./doc/css/style.css" + ], + "scripts": [ + "./doc/scripts/header.js" + ] +} diff --git a/inch.json b/inch.json deleted file mode 100644 index bb05fa6..0000000 --- a/inch.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "files" : { - "included": [ "js/src/**/*.js" ] - } -} diff --git a/js/dist/binomial-heap.js b/js/dist/binomial-heap.js deleted file mode 100644 index 7cac1e7..0000000 --- a/js/dist/binomial-heap.js +++ /dev/null @@ -1,891 +0,0 @@ -"use strict"; - -(function () { - - "use strict"; - - var definition = function definition(exports, undefined) { - - /* js/src/BinomialHeap.js */ - var BinomialHeap = function BinomialHeap(BinomialTree) { - - var binomial_heap_push = function binomial_heap_push(compare, list, tree, rank) { - - var i, len; - - // ensures list has at least rank cells - - i = rank - list.length; - - while (i-- > 0) { - list.push(null); - } - - // loop invariant - // tree and list[i] have the same rank - - len = list.length; - - for (i = rank; i < len && list[i] !== null; ++i) { - - // there is already a tree with this rank - - tree = tree.merge(compare, list[i]); - list[i] = null; - } - - // do not forget to append null if - // we are lacking space - - if (i === len) { - list.push(null); - } - - // cell is empty - // we can just put the new tree here - - list[i] = tree; - }; - - var merge = function merge(compare, list, other) { - - var i, len, carry; - - if (other.length === 0) { - return; - } - - // merging two binomial heaps is like - // adding two little endian integers - // so, we first make sure that we have - // enough place to store the result - - i = other.length - list.length; - - while (i-- > 0) { - list.push(null); - } - - carry = null; - - len = list.length; - - // remember len >= other.length - - for (i = 0; i < len; ++i) { - - // other[i] can be either null or not - // list[i] can be either null or not - // carry can be either null or not - // --> 2^3 = 8 possibilities - // - // null ? | other[i] | list[i] | carry - // --------------------------------------- - // (0) | no | no | no - // (1) | no | no | yes - // (2) | no | yes | no - // (3) | no | yes | yes - // (4) | yes | no | no - // (5) | yes | no | yes - // (6) | yes | yes | no - // (7) | yes | yes | yes - - if (i >= other.length || other[i] === null) { - - if (carry !== null) { - - // (6) other[i] = null and list[i] = null and carry != null - // --> put carry in current cell - - if (list[i] === null) { - list[i] = carry; - carry = null; - } - - // (4) other[i] = null and list[i] != null and carry != null - // --> merge carry with current cell - - else { - carry = carry.merge(compare, list[i]); - list[i] = null; - } - } - - // We do not need to do anything for - // those 2 cases (carry and other[i] are null). - // == - // (5) other[i] = null and list[i] != null and carry = null - // (7) other[i] = null and list[i] = null and carry = null - } - - // (0) other[i] != null and list[i] != null and carry != null - // (2) other[i] != null and list[i] = null and carry != null - // --> merge carry with other[i] - - else if (carry !== null) { - - carry = carry.merge(compare, other[i]); - } - - // (1) other[i] != null and list[i] != null and carry = null - // --> merge current cell with other[i] - - else if (list[i] !== null) { - - carry = list[i].merge(compare, other[i]); - list[i] = null; - } - - // (3) other[i] != null and list[i] = null and carry = null - // --> put other[i] in list - - else { - - list[i] = other[i]; - } - } - - // do not forget to append last carry - - if (carry !== null) { - list.push(carry); - } - }; - - var find_min_index = function find_min_index(compare, list, j, len) { - - var i, opt, item, candidate; - - // there MUST be at least one - // non null element in this list - // we look for the first one - - for (; j < len - 1 && list[j] === null; ++j); - - // here j is necessarily < len - // and list[j] is non null - - i = j; - opt = list[j].value; - - // we lookup remaining elements to see if there - // is not a better candidate - - for (++j; j < len; ++j) { - - item = list[j]; - - if (item !== null) { - - candidate = item.value; - - if (compare(candidate, opt) < 0) { - - i = j; - opt = candidate; - } - } - } - - return i; - }; - - var remove_head_at_index = function remove_head_at_index(compare, list, i, len) { - - var orphans; - - orphans = list[i].children; - list[i] = null; - - change_parent(null, orphans); - - // we just removed the ith element - // if list[i] is the last cell - // of list we can drop it - - if (i === len - 1) { - list.pop(); - } - - // we merge back the children of - // the removed tree into the heap - - merge(compare, list, orphans); - }; - - var binomial_heap_pop = function binomial_heap_pop(compare, list) { - - var i, len, tree; - - len = list.length; - - i = find_min_index(compare, list, 0, len); - - tree = list[i]; - - remove_head_at_index(compare, list, i, len); - - return tree; - }; - - var change_parent = function change_parent(parent, children) { - - var i, len; - - for (i = 0, len = children.length; i < len; ++i) { - children[i].setparent(parent); - } - }; - - var shift_up = function shift_up(tree, parent) { - - var tmp, i; - - // console.log( "tree", tree.value ); - // console.log( "parent", parent.value ); - - // Here, we cannot just swap values as it would invalidate - // externally stored references. - // Instead, we swap children lists and update references - // between the tree and its parent. - // Then we update and return the new tree's parent. - - // console.log( "tree.children", tree.children ); - // console.log( "parent.children", parent.children ); - - tmp = parent.children; - parent.children = tree.children; - tree.children = tmp; - - i = parent.rank(); - - // console.log( tree.children, i ); - - tree.children[i] = parent; - - tree.parent = parent.parent; - - change_parent(tree, tree.children); - change_parent(parent, parent.children); - - // console.log( "tree.children", tree.children ); - // console.log( "parent.children", parent.children ); - - return tree.parent; - }; - - var percolate_up = function percolate_up(list, tree) { - - var tmp, parent; - - parent = tree.parent; - - if (parent !== null) { - - while (true) { - - parent = shift_up(tree, parent); - - if (parent === null) { - break; - } - - // TODO this call might not be necessary - parent.children[tree.rank()] = tree; - } - - list[tree.rank()] = tree; - } - }; - - var decreasekey = function decreasekey(compare, list, tree, value) { - - var d, tmp, parent; - - tree.value = value; - parent = tree.parent; - - if (parent !== null) { - - while (true) { - - d = compare(value, parent.value); - - if (d >= 0) { - return; - } - - parent = shift_up(tree, parent); - - if (parent === null) { - break; - } - - // TODO this call should be in if ( d >= 0 ) - parent.children[tree.rank()] = tree; - } - - list[tree.rank()] = tree; - } - }; - - var deletetree = function deletetree(compare, list, tree) { - - percolate_up(list, tree); - - remove_head_at_index(compare, list, tree.rank(), list.length); - - tree.detach(); - }; - - var Heap = function Heap(compare) { - - // the compare function to use to compare values - - this.compare = compare; - - // number of elements in this heap - - this.length = 0; - - // list of binomial trees - - this.list = []; - }; - - Heap.prototype.head = function () { - - var i, tree; - - if (this.length === 0) { - return undefined; - } - - i = find_min_index(this.compare, this.list, 0, this.list.length); - - tree = this.list[i]; - - return tree.value; - }; - - Heap.prototype.headreference = function () { - - var i, tree; - - if (this.length === 0) { - return null; - } - - i = find_min_index(this.compare, this.list, 0, this.list.length); - - tree = this.list[i]; - - return tree; - }; - - Heap.prototype.pop = function () { - - if (this.length === 0) { - return undefined; - } - - --this.length; - - return binomial_heap_pop(this.compare, this.list).value; - }; - - Heap.prototype.popreference = function () { - - if (this.length === 0) { - return null; - } - - --this.length; - - return binomial_heap_pop(this.compare, this.list).detach(); - }; - - Heap.prototype.push = function (value) { - - var tree; - - // push a new tree of rank 0 - - tree = new BinomialTree(value, []); - - this.pushreference(tree); - - return tree; - }; - - Heap.prototype.pushreference = function (tree) { - - ++this.length; - - // push an existing tree of rank 0 - - binomial_heap_push(this.compare, this.list, tree, 0); - }; - - Heap.prototype.merge = function (other) { - - merge(this.compare, this.list, other.list); - - this.length += other.length; - - return this; - }; - - Heap.prototype.update = function (tree, value) { - - var d; - - d = this.compare(value, tree.value); - - if (d < 0) { - this.decreasekey(tree, value); - } else if (d > 0) { - this.increasekey(tree, value); - } else { - - // d === 0 does not imply tree.value === value - - tree.value = value; - } - }; - - Heap.prototype.decreasekey = function (tree, value) { - - decreasekey(this.compare, this.list, tree, value); - }; - - Heap.prototype.increasekey = function (tree, value) { - - deletetree(this.compare, this.list, tree); - - tree.value = value; - - binomial_heap_push(this.compare, this.list, tree, 0); - }; - - Heap.prototype["delete"] = function (tree) { - - --this.length; - - deletetree(this.compare, this.list, tree); - }; - - return Heap; - }; - - exports.BinomialHeap = BinomialHeap; - - /* js/src/BinomialTree.js */ - - var BinomialTree = function BinomialTree(value, children) { - this.value = value; - this.children = children; - }; - - /** - * /!\ Can only be used to merge two trees of the same rank. - * /!\ Modifies both trees - */ - - BinomialTree.prototype.merge = function (predicate, other) { - - if (predicate(this.value, other.value) <= 0) { - this.children = this.children.concat(other); - return this; - } else { - other.children = other.children.concat(this); - return other; - } - }; - - /** - * Method used to reset a tree element in order to reuse it - * somewhere else, e.g. insert it back in the same or a new - * heap. - */ - - BinomialTree.prototype.detach = function () { - this.children.splice(0); - return this; - }; - - BinomialTree.prototype.setparent = function (parent) {}; - - exports.BinomialTree = BinomialTree; - - /* js/src/BinomialTreeWithParent.js */ - - var BinomialTreeWithParent = function BinomialTreeWithParent(value, children) { - this.value = value; - this.children = children; - this.parent = null; - }; - - BinomialTreeWithParent.prototype.rank = function () { - return this.children.length; - }; - - /** - * /!\ Can only be used to merge two trees of the same rank. - * /!\ Modifies both trees - */ - - BinomialTreeWithParent.prototype.merge = function (predicate, other) { - - if (predicate(this.value, other.value) <= 0) { - this.children = this.children.concat(other); - other.parent = this; - return this; - } else { - other.children = other.children.concat(this); - this.parent = other; - return other; - } - }; - - /** - * Method used to reset a tree element in order to reuse it - * somewhere else, e.g. insert it back in the same or a new - * heap. - */ - - BinomialTreeWithParent.prototype.detach = function () { - this.children.splice(0); - this.parent = null; - return this; - }; - - BinomialTreeWithParent.prototype.setparent = function (parent) { - this.parent = parent; - }; - - exports.BinomialTreeWithParent = BinomialTreeWithParent; - - /* js/src/LazyBinomialHeap.js */ - - var LazyBinomialHeap = function LazyBinomialHeap(BinomialTree) { - - var lazy_binomial_heap_push = function lazy_binomial_heap_push(lazy, tree, rank) { - - var i, sequence; - - // lightweight binomial heap containing a unique tree - - sequence = []; - - // offset tree by its rank - - i = rank; - - while (i--) { - sequence.push(null); - } - - sequence.push(tree); - - // do not merge the generated sequence immediately - - lazy.push(sequence); - }; - - var merge = function merge(compare, list, other) { - - var i, len, carry; - - if (other.length === 0) { - return; - } - - // merging two binomial heaps is like - // adding two little endian integers - // so, we first make sure that we have - // enough place to store the result - - i = other.length - list.length; - - while (i-- > 0) { - list.push(null); - } - - carry = null; - - len = list.length; - - // remember len >= other.length - - for (i = 0; i < len; ++i) { - - // other[i] can be either null or not - // list[i] can be either null or not - // carry can be either null or not - // --> 2^3 = 8 possibilities - // - // null ? | other[i] | list[i] | carry - // --------------------------------------- - // (0) | no | no | no - // (1) | no | no | yes - // (2) | no | yes | no - // (3) | no | yes | yes - // (4) | yes | no | no - // (5) | yes | no | yes - // (6) | yes | yes | no - // (7) | yes | yes | yes - - if (i >= other.length || other[i] === null) { - - if (carry !== null) { - - // (6) other[i] = null and list[i] = null and carry != null - // --> put carry in current cell - - if (list[i] === null) { - list[i] = carry; - carry = null; - } - - // (4) other[i] = null and list[i] != null and carry != null - // --> merge carry with current cell - - else { - carry = carry.merge(compare, list[i]); - list[i] = null; - } - } - - // We do not need to do anything for - // those 2 cases (carry and other[i] are null). - // == - // (5) other[i] = null and list[i] != null and carry = null - // (7) other[i] = null and list[i] = null and carry = null - } - - // (0) other[i] != null and list[i] != null and carry != null - // (2) other[i] != null and list[i] = null and carry != null - // --> merge carry with other[i] - - else if (carry !== null) { - - carry = carry.merge(compare, other[i]); - } - - // (1) other[i] != null and list[i] != null and carry = null - // --> merge current cell with other[i] - - else if (list[i] !== null) { - - carry = list[i].merge(compare, other[i]); - list[i] = null; - } - - // (3) other[i] != null and list[i] = null and carry = null - // --> put other[i] in list - - else { - - list[i] = other[i]; - } - } - - // do not forget to append last carry - - if (carry !== null) { - list.push(carry); - } - }; - - var lazy_binomial_heap_pop = function lazy_binomial_heap_pop(compare, list, lazy) { - - var i, j, len, opt, item, candidate, orphan; - - // amortized merge of - // stored values - - while (!lazy.empty()) merge(compare, list, lazy.pop()); - - // standard O(log n) optimum search method - - len = list.length; - - // there MUST be at least one - // non null element in this list - // we look for the first one - - for (j = 0; j < len - 1 && list[j] === null; ++j); - - // here j is necessarily < len - // and list[j] is non null - - i = j; - opt = list[j].value; - - // we lookup remaining elements to see if there - // is not a better candidate - - for (++j; j < len; ++j) { - - item = list[j]; - - if (item !== null) { - - candidate = item.value; - - if (compare(candidate, opt) < 0) { - - i = j; - opt = candidate; - } - } - } - - orphan = list[i].children; - list[i] = null; - - // we just removed the ith element - // if list[i] is the last cell - // of list we can drop it - - if (i === len - 1) { - list.pop(); - } - - // we store the children in the - // lazy list - - lazy.push(orphan); - - return opt; - }; - - var Heap = function Heap(compare) { - - // the compare function to use to compare values - - this.compare = compare; - - // number of elements in this heap - - this.length = 0; - - // list of binomial trees - - this.list = []; - - // list of binomial heaps waiting to be merged - - this.lazy = new LazyStack(); - }; - - Heap.prototype.pop = function () { - - if (this.length === 0) { - return undefined; - } - - --this.length; - - return lazy_binomial_heap_pop(this.compare, this.list, this.lazy); - }; - - Heap.prototype.push = function (value) { - - ++this.length; - - // push a new tree of rank 0 - - return lazy_binomial_heap_push(this.lazy, new BinomialTree(value, []), 0); - }; - - Heap.prototype.merge = function (other) { - - this.lazy.meld(other.lazy); - - this.length += other.length; - - return this; - }; - - return Heap; - }; - - exports.LazyBinomialHeap = LazyBinomialHeap; - - /* js/src/LazyList.js */ - - /** - * LazyStack#peek only valid if LazyStack#empty is false. - * LazyStack#shift only valid if LazyStack#empty is false. - */ - - var LazyStack = function LazyStack() { - - this.top = null; - this.bottom = null; - }; - - LazyStack.prototype.empty = function () { - - return this.top === null; - }; - - LazyStack.prototype.push = function (value) { - - this.top = new LazyNode(value, this.top); - - if (this.bottom === null) this.bottom = this.top; - }; - - /** - * Only valid if LazyStack#empty is false. - */ - - LazyStack.prototype.pop = function () { - - var value; - - value = this.top.value; - - this.top = this.top.next; - - if (this.top === null) this.bottom = null; - - return value; - }; - - LazyStack.prototype.meld = function (other) { - - if (this.bottom === null) this.top = other.top;else this.bottom.next = other.top; - - this.bottom = other.bottom; - }; - - exports.LazyStack = LazyStack; - - /* js/src/LazyNode.js */ - - var LazyNode = function LazyNode(value, next) { - - this.value = value; - this.next = next; - }; - - exports.LazyNode = LazyNode; - - return exports; - }; - if (typeof exports === "object") { - definition(exports); - } else if (typeof define === "function" && define.amd) { - define("aureooms-js-binomial-heap", [], function () { - return definition({}); - }); - } else if (typeof window === "object" && typeof window.document === "object") { - definition(window["binomialheap"] = {}); - } else console.error("unable to detect type of module to define for aureooms-js-binomial-heap"); -})(); - -// we do not keep track of any parent here \ No newline at end of file diff --git a/js/dist/binomial-heap.js.map b/js/dist/binomial-heap.js.map deleted file mode 100644 index 6fc76bd..0000000 --- a/js/dist/binomial-heap.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"js/dist/binomial-heap.js.map","sources":["js/dist/binomial-heap.js"],"names":["definition","exports","undefined","BinomialHeap","BinomialTree","binomial_heap_push","compare","list","tree","rank","i","len","length","push","merge","other","carry","find_min_index","j","opt","item","candidate","value","remove_head_at_index","orphans","children","change_parent","pop","binomial_heap_pop","parent","setparent","shift_up","tmp","percolate_up","decreasekey","d","deletetree","detach","Heap","this","prototype","head","headreference","popreference","pushreference","update","increasekey","predicate","concat","splice","BinomialTreeWithParent","LazyBinomialHeap","lazy_binomial_heap_push","lazy","sequence","lazy_binomial_heap_pop","orphan","empty","LazyStack","meld","top","bottom","LazyNode","next","define","amd","window","document","console","error"],"mappings":"AAAA,cAEA,WAIC,GAAIA,GAAa,SAAoBC,EAASC,GAG7C,GAAIC,GAAe,SAAsBC,GAExC,GAAIC,GAAqB,SAA4BC,EAASC,EAAMC,EAAMC,GAEzE,GAAIC,GAAGC,CAMP,KAFAD,EAAID,EAAOF,EAAKK,OAETF,IAAM,GACZH,EAAKM,KAAK,KAQX,KAFAF,EAAMJ,EAAKK,OAENF,EAAID,EAAUE,EAAJD,GAAuB,OAAZH,EAAKG,KAAeA,EAI7CF,EAAOA,EAAKM,MAAMR,EAASC,EAAKG,IAChCH,EAAKG,GAAK,IAMPA,KAAMC,GACTJ,EAAKM,KAAK,MAMXN,EAAKG,GAAKF,GAGPM,EAAQ,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M,GAAIE,GAASxC,EAAOiB,KAAKqB,KAEhB,OAAhBrB,KAAKsB,SAAiBtB,KAAKsB,OAAStB,KAAKqB,MAO9CF,EAAUlB,UAAUb,IAAM,WAEzB,GAAIL,EAQJ,OANAA,GAAQiB,KAAKqB,IAAItC,MAEjBiB,KAAKqB,IAAMrB,KAAKqB,IAAIG,KAEH,OAAbxB,KAAKqB,MAAcrB,KAAKsB,OAAS,MAE9BvC,GAGRoC,EAAUlB,UAAUmB,KAAO,SAAU5C,GAEhB,OAAhBwB,KAAKsB,OAAiBtB,KAAKqB,IAAM7C,EAAM6C,IAASrB,KAAKsB,OAAOE,KAAOhD,EAAM6C,IAE7ErB,KAAKsB,OAAS9C,EAAM8C,QAGrB5D,EAAQyD,UAAYA,CAIpB,IAAII,GAAW,SAAkBxC,EAAOyC,GAEvCxB,KAAKjB,MAAQA,EACbiB,KAAKwB,KAAOA,EAKb,OAFA9D,GAAQ6D,SAAWA,EAEZ7D,EAEe,iBAAZA,SACVD,EAAWC,SACiB,kBAAX+D,SAAyBA,OAAOC,IACjDD,OAAO,+BAAiC,WACvC,MAAOhE,SAEoB,gBAAXkE,SAAkD,gBAApBA,QAAOC,SACtDnE,EAAWkE,OAAqB,iBAC1BE,QAAQC,MAAM"} \ No newline at end of file diff --git a/js/dist/binomial-heap.min.js b/js/dist/binomial-heap.min.js deleted file mode 100644 index 556f668..0000000 --- a/js/dist/binomial-heap.min.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict";!function(){var t=function(t,n){var e=function(t){var e=function(t,n,e,i){var l,r;for(l=i-n.length;l-->0;)n.push(null);for(r=n.length,l=i;r>l&&null!==n[l];++l)e=e.merge(t,n[l]),n[l]=null;l===r&&n.push(null),n[l]=e},i=function(t,n,e){var i,l,r;if(0!==e.length){for(i=e.length-n.length;i-->0;)n.push(null);for(r=null,l=n.length,i=0;l>i;++i)i>=e.length||null===e[i]?null!==r&&(null===n[i]?(n[i]=r,r=null):(r=r.merge(t,n[i]),n[i]=null)):null!==r?r=r.merge(t,e[i]):null!==n[i]?(r=n[i].merge(t,e[i]),n[i]=null):n[i]=e[i];null!==r&&n.push(r)}},l=function(t,n,e,i){for(var l,r,o,h;i-1>e&&null===n[e];++e);for(l=e,r=n[e].value,++e;i>e;++e)o=n[e],null!==o&&(h=o.value,t(h,r)<0&&(l=e,r=h));return l},r=function(t,n,e,l){var r;r=n[e].children,n[e]=null,h(null,r),e===l-1&&n.pop(),i(t,n,r)},o=function(t,n){var e,i,o;return i=n.length,e=l(t,n,0,i),o=n[e],r(t,n,e,i),o},h=function(t,n){var e,i;for(e=0,i=n.length;i>e;++e)n[e].setparent(t)},u=function(t,n){var e,i;return e=n.children,n.children=t.children,t.children=e,i=n.rank(),t.children[i]=n,t.parent=n.parent,h(t,t.children),h(n,n.children),t.parent},s=function(t,n){var e;if(e=n.parent,null!==e){for(;;){if(e=u(n,e),null===e)break;e.children[n.rank()]=n}t[n.rank()]=n}},p=function(t,n,e,i){var l,r;if(e.value=i,r=e.parent,null!==r){for(;;){if(l=t(i,r.value),l>=0)return;if(r=u(e,r),null===r)break;r.children[e.rank()]=e}n[e.rank()]=e}},a=function(t,n,e){s(n,e),r(t,n,e.rank(),n.length),e.detach()},c=function(t){this.compare=t,this.length=0,this.list=[]};return c.prototype.head=function(){var t,e;return 0===this.length?n:(t=l(this.compare,this.list,0,this.list.length),e=this.list[t],e.value)},c.prototype.headreference=function(){var t,n;return 0===this.length?null:(t=l(this.compare,this.list,0,this.list.length),n=this.list[t])},c.prototype.pop=function(){return 0===this.length?n:(--this.length,o(this.compare,this.list).value)},c.prototype.popreference=function(){return 0===this.length?null:(--this.length,o(this.compare,this.list).detach())},c.prototype.push=function(n){var e;return e=new t(n,[]),this.pushreference(e),e},c.prototype.pushreference=function(t){++this.length,e(this.compare,this.list,t,0)},c.prototype.merge=function(t){return i(this.compare,this.list,t.list),this.length+=t.length,this},c.prototype.update=function(t,n){var e;e=this.compare(n,t.value),0>e?this.decreasekey(t,n):e>0?this.increasekey(t,n):t.value=n},c.prototype.decreasekey=function(t,n){p(this.compare,this.list,t,n)},c.prototype.increasekey=function(t,n){a(this.compare,this.list,t),t.value=n,e(this.compare,this.list,t,0)},c.prototype["delete"]=function(t){--this.length,a(this.compare,this.list,t)},c};t.BinomialHeap=e;var i=function(t,n){this.value=t,this.children=n};i.prototype.merge=function(t,n){return t(this.value,n.value)<=0?(this.children=this.children.concat(n),this):(n.children=n.children.concat(this),n)},i.prototype.detach=function(){return this.children.splice(0),this},i.prototype.setparent=function(t){},t.BinomialTree=i;var l=function(t,n){this.value=t,this.children=n,this.parent=null};l.prototype.rank=function(){return this.children.length},l.prototype.merge=function(t,n){return t(this.value,n.value)<=0?(this.children=this.children.concat(n),n.parent=this,this):(n.children=n.children.concat(this),this.parent=n,n)},l.prototype.detach=function(){return this.children.splice(0),this.parent=null,this},l.prototype.setparent=function(t){this.parent=t},t.BinomialTreeWithParent=l;var r=function(t){var e=function(t,n,e){var i,l;for(l=[],i=e;i--;)l.push(null);l.push(n),t.push(l)},i=function(t,n,e){var i,l,r;if(0!==e.length){for(i=e.length-n.length;i-->0;)n.push(null);for(r=null,l=n.length,i=0;l>i;++i)i>=e.length||null===e[i]?null!==r&&(null===n[i]?(n[i]=r,r=null):(r=r.merge(t,n[i]),n[i]=null)):null!==r?r=r.merge(t,e[i]):null!==n[i]?(r=n[i].merge(t,e[i]),n[i]=null):n[i]=e[i];null!==r&&n.push(r)}},l=function(t,n,e){for(var l,r,o,h,u,s,p;!e.empty();)i(t,n,e.pop());for(o=n.length,r=0;o-1>r&&null===n[r];++r);for(l=r,h=n[r].value,++r;o>r;++r)u=n[r],null!==u&&(s=u.value,t(s,h)<0&&(l=r,h=s));return p=n[l].children,n[l]=null,l===o-1&&n.pop(),e.push(p),h},r=function(t){this.compare=t,this.length=0,this.list=[],this.lazy=new o};return r.prototype.pop=function(){return 0===this.length?n:(--this.length,l(this.compare,this.list,this.lazy))},r.prototype.push=function(n){return++this.length,e(this.lazy,new t(n,[]),0)},r.prototype.merge=function(t){return this.lazy.meld(t.lazy),this.length+=t.length,this},r};t.LazyBinomialHeap=r;var o=function(){this.top=null,this.bottom=null};o.prototype.empty=function(){return null===this.top},o.prototype.push=function(t){this.top=new h(t,this.top),null===this.bottom&&(this.bottom=this.top)},o.prototype.pop=function(){var t;return t=this.top.value,this.top=this.top.next,null===this.top&&(this.bottom=null),t},o.prototype.meld=function(t){null===this.bottom?this.top=t.top:this.bottom.next=t.top,this.bottom=t.bottom},t.LazyStack=o;var h=function(t,n){this.value=t,this.next=n};return t.LazyNode=h,t};"object"==typeof exports?t(exports):"function"==typeof define&&define.amd?define("aureooms-js-binomial-heap",[],function(){return t({})}):"object"==typeof window&&"object"==typeof window.document?t(window.binomialheap={}):console.error("unable to detect type of module to define for aureooms-js-binomial-heap")}(); -//# sourceMappingURL=js/dist/binomial-heap.js.map \ No newline at end of file diff --git a/js/index.js b/js/index.js deleted file mode 100644 index e6e928c..0000000 --- a/js/index.js +++ /dev/null @@ -1,15 +0,0 @@ -var pkg = require('aureooms-node-package'); - -var fs = require('fs'); -var data = fs.readFileSync(pkg.config, 'utf8'); -var opt = JSON.parse(data); - -opt = { - name : opt.name, - src : __dirname + '/src/', - exports : module.exports, - base : 0, - debug : opt.debug -}; - -pkg.include(opt); diff --git a/js/src/LazyNode.js b/js/src/LazyNode.js deleted file mode 100644 index d488fbd..0000000 --- a/js/src/LazyNode.js +++ /dev/null @@ -1,9 +0,0 @@ - -var LazyNode = function ( value , next ) { - - this.value = value ; - this.next = next ; - -} ; - -exports.LazyNode = LazyNode ; diff --git a/lib/BinomialHeap.js b/lib/BinomialHeap.js new file mode 100644 index 0000000..347563b --- /dev/null +++ b/lib/BinomialHeap.js @@ -0,0 +1,477 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = BinomialHeap; +function BinomialHeap(BinomialTree) { + + var binomial_heap_push = function binomial_heap_push(compare, list, tree, rank) { + + var i, len; + + // ensures list has at least rank cells + + i = rank - list.length; + + while (i-- > 0) { + list.push(null); + } + + // loop invariant + // tree and list[i] have the same rank + + len = list.length; + + for (i = rank; i < len && list[i] !== null; ++i) { + + // there is already a tree with this rank + + tree = tree.merge(compare, list[i]); + list[i] = null; + } + + // do not forget to append null if + // we are lacking space + + if (i === len) { + list.push(null); + } + + // cell is empty + // we can just put the new tree here + + list[i] = tree; + }; + + var merge = function merge(compare, list, other) { + + var i, len, carry; + + if (other.length === 0) { + return; + } + + // merging two binomial heaps is like + // adding two little endian integers + // so, we first make sure that we have + // enough place to store the result + + i = other.length - list.length; + + while (i-- > 0) { + list.push(null); + } + + carry = null; + + len = list.length; + + // remember len >= other.length + + for (i = 0; i < len; ++i) { + + // other[i] can be either null or not + // list[i] can be either null or not + // carry can be either null or not + // --> 2^3 = 8 possibilities + // + // null ? | other[i] | list[i] | carry + // --------------------------------------- + // (0) | no | no | no + // (1) | no | no | yes + // (2) | no | yes | no + // (3) | no | yes | yes + // (4) | yes | no | no + // (5) | yes | no | yes + // (6) | yes | yes | no + // (7) | yes | yes | yes + + if (i >= other.length || other[i] === null) { + + if (carry !== null) { + + // (6) other[i] = null and list[i] = null and carry != null + // --> put carry in current cell + + if (list[i] === null) { + list[i] = carry; + carry = null; + } + + // (4) other[i] = null and list[i] != null and carry != null + // --> merge carry with current cell + + else { + carry = carry.merge(compare, list[i]); + list[i] = null; + } + } + + // We do not need to do anything for + // those 2 cases (carry and other[i] are null). + // == + // (5) other[i] = null and list[i] != null and carry = null + // (7) other[i] = null and list[i] = null and carry = null + } + + // (0) other[i] != null and list[i] != null and carry != null + // (2) other[i] != null and list[i] = null and carry != null + // --> merge carry with other[i] + + else if (carry !== null) { + + carry = carry.merge(compare, other[i]); + } + + // (1) other[i] != null and list[i] != null and carry = null + // --> merge current cell with other[i] + + else if (list[i] !== null) { + + carry = list[i].merge(compare, other[i]); + list[i] = null; + } + + // (3) other[i] != null and list[i] = null and carry = null + // --> put other[i] in list + + else { + + list[i] = other[i]; + } + } + + // do not forget to append last carry + + if (carry !== null) { + list.push(carry); + } + }; + + var find_min_index = function find_min_index(compare, list, j, len) { + + var i, opt, item, candidate; + + // there MUST be at least one + // non null element in this list + // we look for the first one + + for (; j < len - 1 && list[j] === null; ++j) {} + + // here j is necessarily < len + // and list[j] is non null + + i = j; + opt = list[j].value; + + // we lookup remaining elements to see if there + // is not a better candidate + + for (++j; j < len; ++j) { + + item = list[j]; + + if (item !== null) { + + candidate = item.value; + + if (compare(candidate, opt) < 0) { + + i = j; + opt = candidate; + } + } + } + + return i; + }; + + var remove_head_at_index = function remove_head_at_index(compare, list, i, len) { + + var orphans; + + orphans = list[i].children; + list[i] = null; + + change_parent(null, orphans); + + // we just removed the ith element + // if list[i] is the last cell + // of list we can drop it + + if (i === len - 1) { + list.pop(); + } + + // we merge back the children of + // the removed tree into the heap + + merge(compare, list, orphans); + }; + + var binomial_heap_pop = function binomial_heap_pop(compare, list) { + + var i, len, tree; + + len = list.length; + + i = find_min_index(compare, list, 0, len); + + tree = list[i]; + + remove_head_at_index(compare, list, i, len); + + return tree; + }; + + var change_parent = function change_parent(parent, children) { + + var i, len; + + for (i = 0, len = children.length; i < len; ++i) { + children[i].setparent(parent); + } + }; + + var shift_up = function shift_up(tree, parent) { + + var tmp, i; + + // console.log( "tree", tree.value ); + // console.log( "parent", parent.value ); + + // Here, we cannot just swap values as it would invalidate + // externally stored references. + // Instead, we swap children lists and update references + // between the tree and its parent. + // Then we update and return the new tree's parent. + + // console.log( "tree.children", tree.children ); + // console.log( "parent.children", parent.children ); + + tmp = parent.children; + parent.children = tree.children; + tree.children = tmp; + + i = parent.rank(); + + // console.log( tree.children, i ); + + tree.children[i] = parent; + + tree.parent = parent.parent; + + change_parent(tree, tree.children); + change_parent(parent, parent.children); + + // console.log( "tree.children", tree.children ); + // console.log( "parent.children", parent.children ); + + return tree.parent; + }; + + var percolate_up = function percolate_up(list, tree) { + + var tmp, parent; + + parent = tree.parent; + + if (parent !== null) { + + while (true) { + + parent = shift_up(tree, parent); + + if (parent === null) { + break; + } + + // TODO this call might not be necessary + parent.children[tree.rank()] = tree; + } + + list[tree.rank()] = tree; + } + }; + + var decreasekey = function decreasekey(compare, list, tree, value) { + + var d, tmp, parent; + + tree.value = value; + parent = tree.parent; + + if (parent !== null) { + + while (true) { + + d = compare(value, parent.value); + + if (d >= 0) { + return; + } + + parent = shift_up(tree, parent); + + if (parent === null) { + break; + } + + // TODO this call should be in if ( d >= 0 ) + parent.children[tree.rank()] = tree; + } + + list[tree.rank()] = tree; + } + }; + + var deletetree = function deletetree(compare, list, tree) { + + percolate_up(list, tree); + + remove_head_at_index(compare, list, tree.rank(), list.length); + + tree.detach(); + }; + + var Heap = function Heap(compare) { + + // the compare function to use to compare values + + this.compare = compare; + + // number of elements in this heap + + this.length = 0; + + // list of binomial trees + + this.list = []; + }; + + Heap.prototype.head = function () { + + var i, tree; + + if (this.length === 0) { + return undefined; + } + + i = find_min_index(this.compare, this.list, 0, this.list.length); + + tree = this.list[i]; + + return tree.value; + }; + + Heap.prototype.headreference = function () { + + var i, tree; + + if (this.length === 0) { + return null; + } + + i = find_min_index(this.compare, this.list, 0, this.list.length); + + tree = this.list[i]; + + return tree; + }; + + Heap.prototype.pop = function () { + + if (this.length === 0) { + return undefined; + } + + --this.length; + + return binomial_heap_pop(this.compare, this.list).value; + }; + + Heap.prototype.popreference = function () { + + if (this.length === 0) { + return null; + } + + --this.length; + + return binomial_heap_pop(this.compare, this.list).detach(); + }; + + Heap.prototype.push = function (value) { + + var tree; + + // push a new tree of rank 0 + + tree = new BinomialTree(value, []); + + this.pushreference(tree); + + return tree; + }; + + Heap.prototype.pushreference = function (tree) { + + ++this.length; + + // push an existing tree of rank 0 + + binomial_heap_push(this.compare, this.list, tree, 0); + }; + + Heap.prototype.merge = function (other) { + + merge(this.compare, this.list, other.list); + + this.length += other.length; + + return this; + }; + + Heap.prototype.update = function (tree, value) { + + var d; + + d = this.compare(value, tree.value); + + if (d < 0) { + this.decreasekey(tree, value); + } else if (d > 0) { + this.increasekey(tree, value); + } else { + + // d === 0 does not imply tree.value === value + + tree.value = value; + } + }; + + Heap.prototype.decreasekey = function (tree, value) { + + decreasekey(this.compare, this.list, tree, value); + }; + + Heap.prototype.increasekey = function (tree, value) { + + deletetree(this.compare, this.list, tree); + + tree.value = value; + + binomial_heap_push(this.compare, this.list, tree, 0); + }; + + Heap.prototype.delete = function (tree) { + + --this.length; + + deletetree(this.compare, this.list, tree); + }; + + return Heap; +} +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9CaW5vbWlhbEhlYXAuanMiXSwibmFtZXMiOlsiQmlub21pYWxIZWFwIiwiQmlub21pYWxUcmVlIiwiYmlub21pYWxfaGVhcF9wdXNoIiwiY29tcGFyZSIsImxpc3QiLCJ0cmVlIiwicmFuayIsImkiLCJsZW4iLCJsZW5ndGgiLCJwdXNoIiwibWVyZ2UiLCJvdGhlciIsImNhcnJ5IiwiZmluZF9taW5faW5kZXgiLCJqIiwib3B0IiwiaXRlbSIsImNhbmRpZGF0ZSIsInZhbHVlIiwicmVtb3ZlX2hlYWRfYXRfaW5kZXgiLCJvcnBoYW5zIiwiY2hpbGRyZW4iLCJjaGFuZ2VfcGFyZW50IiwicG9wIiwiYmlub21pYWxfaGVhcF9wb3AiLCJwYXJlbnQiLCJzZXRwYXJlbnQiLCJzaGlmdF91cCIsInRtcCIsInBlcmNvbGF0ZV91cCIsImRlY3JlYXNla2V5IiwiZCIsImRlbGV0ZXRyZWUiLCJkZXRhY2giLCJIZWFwIiwicHJvdG90eXBlIiwiaGVhZCIsInVuZGVmaW5lZCIsImhlYWRyZWZlcmVuY2UiLCJwb3ByZWZlcmVuY2UiLCJwdXNocmVmZXJlbmNlIiwidXBkYXRlIiwiaW5jcmVhc2VrZXkiLCJkZWxldGUiXSwibWFwcGluZ3MiOiI7Ozs7O2tCQUF3QkEsWTtBQUFULFNBQVNBLFlBQVQsQ0FBd0JDLFl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mVlLnZhbHVlID0gdmFsdWU7XG5cblx0XHRiaW5vbWlhbF9oZWFwX3B1c2goIHRoaXMuY29tcGFyZSwgdGhpcy5saXN0LCB0cmVlLCAwICk7XG5cblx0fTtcblxuXHRIZWFwLnByb3RvdHlwZS5kZWxldGUgPSBmdW5jdGlvbiAoIHRyZWUgKSB7XG5cblx0XHQtLXRoaXMubGVuZ3RoO1xuXG5cdFx0ZGVsZXRldHJlZSggdGhpcy5jb21wYXJlLCB0aGlzLmxpc3QsIHRyZWUgKTtcblxuXHR9O1xuXG5cdHJldHVybiBIZWFwO1xuXG59XG4iXX0= \ No newline at end of file diff --git a/lib/BinomialTree.js b/lib/BinomialTree.js new file mode 100644 index 0000000..0418872 --- /dev/null +++ b/lib/BinomialTree.js @@ -0,0 +1,42 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = BinomialTree; +function BinomialTree(value, children) { + this.value = value; + this.children = children; +} + +/** + * /!\ Can only be used to merge two trees of the same rank. + * /!\ Modifies both trees + */ + +BinomialTree.prototype.merge = function (predicate, other) { + + if (predicate(this.value, other.value) <= 0) { + this.children = this.children.concat(other); + return this; + } else { + other.children = other.children.concat(this); + return other; + } +}; + +/** + * Method used to reset a tree element in order to reuse it + * somewhere else, e.g. insert it back in the same or a new + * heap. + */ + +BinomialTree.prototype.detach = function () { + this.children.splice(0); + return this; +}; + +BinomialTree.prototype.setparent = function (parent) { + // we do not keep track of any parent here +}; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9CaW5vbWlhbFRyZWUuanMiXSwibmFtZXMiOlsiQmlub21pYWxUcmVlIiwidmFsdWUiLCJjaGlsZHJlbiIsInByb3RvdHlwZSIsIm1lcmdlIiwicHJlZGljYXRlIiwib3RoZXIiLCJjb25jYXQiLCJkZXRhY2giLCJzcGxpY2UiLCJzZXRwYXJlbnQiLCJwYXJlbnQiXSwibWFwcGluZ3MiOiI7Ozs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JlbiA9IGNoaWxkcmVuO1xufVxuXG4vKipcbiAqIC8hXFwgQ2FuIG9ubHkgYmUgdXNlZCB0byBtZXJnZSB0d28gdHJlZXMgb2YgdGhlIHNhbWUgcmFuay5cbiAqIC8hXFwgTW9kaWZpZXMgYm90aCB0cmVlc1xuICovXG5cbkJpbm9taWFsVHJlZS5wcm90b3R5cGUubWVyZ2UgPSBmdW5jdGlvbiAoIHByZWRpY2F0ZSwgb3RoZXIgKSB7XG5cblx0aWYgKCBwcmVkaWNhdGUoIHRoaXMudmFsdWUsIG90aGVyLnZhbHVlICkgPD0gMCApIHtcblx0XHR0aGlzLmNoaWxkcmVuID0gdGhpcy5jaGlsZHJlbi5jb25jYXQoIG90aGVyICk7XG5cdFx0cmV0dXJuIHRoaXM7XG5cdH1cblxuXHRlbHNlIHtcblx0XHRvdGhlci5jaGlsZHJlbiA9IG90aGVyLmNoaWxkcmVuLmNvbmNhdCggdGhpcyApO1xuXHRcdHJldHVybiBvdGhlcjtcblx0fVxuXG59O1xuXG4vKipcbiAqIE1ldGhvZCB1c2VkIHRvIHJlc2V0IGEgdHJlZSBlbGVtZW50IGluIG9yZGVyIHRvIHJldXNlIGl0XG4gKiBzb21ld2hlcmUgZWxzZSwgZS5nLiBpbnNlcnQgaXQgYmFjayBpbiB0aGUgc2FtZSBvciBhIG5ld1xuICogaGVhcC5cbiAqL1xuXG5CaW5vbWlhbFRyZWUucHJvdG90eXBlLmRldGFjaCA9IGZ1bmN0aW9uICgpIHtcblx0dGhpcy5jaGlsZHJlbi5zcGxpY2UoIDAgKTtcblx0cmV0dXJuIHRoaXM7XG59O1xuXG5CaW5vbWlhbFRyZWUucHJvdG90eXBlLnNldHBhcmVudCA9IGZ1bmN0aW9uICggcGFyZW50ICkge1xuXHQvLyB3ZSBkbyBub3Qga2VlcCB0cmFjayBvZiBhbnkgcGFyZW50IGhlcmVcbn07XG4iXX0= \ No newline at end of file diff --git a/lib/BinomialTreeWithParent.js b/lib/BinomialTreeWithParent.js new file mode 100644 index 0000000..c0ef70a --- /dev/null +++ b/lib/BinomialTreeWithParent.js @@ -0,0 +1,50 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = BinomialTreeWithParent; +function BinomialTreeWithParent(value, children) { + this.value = value; + this.children = children; + this.parent = null; +} + +BinomialTreeWithParent.prototype.rank = function () { + return this.children.length; +}; + +/** + * /!\ Can only be used to merge two trees of the same rank. + * /!\ Modifies both trees + */ + +BinomialTreeWithParent.prototype.merge = function (predicate, other) { + + if (predicate(this.value, other.value) <= 0) { + this.children = this.children.concat(other); + other.parent = this; + return this; + } else { + other.children = other.children.concat(this); + this.parent = other; + return other; + } +}; + +/** + * Method used to reset a tree element in order to reuse it + * somewhere else, e.g. insert it back in the same or a new + * heap. + */ + +BinomialTreeWithParent.prototype.detach = function () { + this.children.splice(0); + this.parent = null; + return this; +}; + +BinomialTreeWithParent.prototype.setparent = function (parent) { + this.parent = parent; +}; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9CaW5vbWlhbFRyZWVXaXRoUGFyZW50LmpzIl0sIm5hbWVzIjpbIkJpbm9taWFsVHJlZVdpdGhQYXJlbnQiLCJ2YWx1ZSIsImNoaWxkcmVuIiwicGFyZW50IiwicHJvdG90eXBlIiwicmFuayIsImxlbmd0aCIsIm1lcmdlIiwicHJlZGljYXRlIiwib3RoZXIiLCJjb25jYXQiLCJkZXRhY2giLCJzcGxpY2UiLCJzZXRwYXJlbnQiXSwibWFwcGluZ3MiOiI7Ozs7O2tCQUV3QkEsc0I7QUFBVCxTQUFTQSxzQkFBVCxDQUFrQ0MsS0FBbEMsRUFBeUNDLFFBQXpDLEVBQW9EO0FBQ2xFLE1BQUtELEtBQUwsR0FBYUEsS0FBYjtBQUNBLE1BQUtDLFFBQUwsR0FBZ0JBLFFBQWhCO0FBQ0EsTUFBS0MsTUFBTCxHQUFjLElBQWQ7QUFDQTs7QUFFREg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bWUgb3IgYSBuZXdcbiAqIGhlYXAuXG4gKi9cblxuQmlub21pYWxUcmVlV2l0aFBhcmVudC5wcm90b3R5cGUuZGV0YWNoID0gZnVuY3Rpb24gKCkge1xuXHR0aGlzLmNoaWxkcmVuLnNwbGljZSggMCApO1xuXHR0aGlzLnBhcmVudCA9IG51bGw7XG5cdHJldHVybiB0aGlzO1xufTtcblxuQmlub21pYWxUcmVlV2l0aFBhcmVudC5wcm90b3R5cGUuc2V0cGFyZW50ID0gZnVuY3Rpb24gKCBwYXJlbnQgKSB7XG5cdHRoaXMucGFyZW50ID0gcGFyZW50O1xufTtcbiJdfQ== \ No newline at end of file diff --git a/lib/LazyBinomialHeap.js b/lib/LazyBinomialHeap.js new file mode 100644 index 0000000..d525ac8 --- /dev/null +++ b/lib/LazyBinomialHeap.js @@ -0,0 +1,257 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = LazyBinomialHeap; + +var _LazyStack = require('./LazyStack'); + +var _LazyStack2 = _interopRequireDefault(_LazyStack); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function LazyBinomialHeap(BinomialTree) { + + var lazy_binomial_heap_push = function lazy_binomial_heap_push(lazy, tree, rank) { + + var i, sequence; + + // lightweight binomial heap containing a unique tree + + sequence = []; + + // offset tree by its rank + + i = rank; + + while (i--) { + sequence.push(null); + } + + sequence.push(tree); + + // do not merge the generated sequence immediately + + lazy.push(sequence); + }; + + var merge = function merge(compare, list, other) { + + var i, len, carry; + + if (other.length === 0) { + return; + } + + // merging two binomial heaps is like + // adding two little endian integers + // so, we first make sure that we have + // enough place to store the result + + i = other.length - list.length; + + while (i-- > 0) { + list.push(null); + } + + carry = null; + + len = list.length; + + // remember len >= other.length + + for (i = 0; i < len; ++i) { + + // other[i] can be either null or not + // list[i] can be either null or not + // carry can be either null or not + // --> 2^3 = 8 possibilities + // + // null ? | other[i] | list[i] | carry + // --------------------------------------- + // (0) | no | no | no + // (1) | no | no | yes + // (2) | no | yes | no + // (3) | no | yes | yes + // (4) | yes | no | no + // (5) | yes | no | yes + // (6) | yes | yes | no + // (7) | yes | yes | yes + + if (i >= other.length || other[i] === null) { + + if (carry !== null) { + + // (6) other[i] = null and list[i] = null and carry != null + // --> put carry in current cell + + if (list[i] === null) { + list[i] = carry; + carry = null; + } + + // (4) other[i] = null and list[i] != null and carry != null + // --> merge carry with current cell + + else { + carry = carry.merge(compare, list[i]); + list[i] = null; + } + } + + // We do not need to do anything for + // those 2 cases (carry and other[i] are null). + // == + // (5) other[i] = null and list[i] != null and carry = null + // (7) other[i] = null and list[i] = null and carry = null + } + + // (0) other[i] != null and list[i] != null and carry != null + // (2) other[i] != null and list[i] = null and carry != null + // --> merge carry with other[i] + + else if (carry !== null) { + + carry = carry.merge(compare, other[i]); + } + + // (1) other[i] != null and list[i] != null and carry = null + // --> merge current cell with other[i] + + else if (list[i] !== null) { + + carry = list[i].merge(compare, other[i]); + list[i] = null; + } + + // (3) other[i] != null and list[i] = null and carry = null + // --> put other[i] in list + + else { + + list[i] = other[i]; + } + } + + // do not forget to append last carry + + if (carry !== null) { + list.push(carry); + } + }; + + var lazy_binomial_heap_pop = function lazy_binomial_heap_pop(compare, list, lazy) { + + var i, j, len, opt, item, candidate, orphan; + + // amortized merge of + // stored values + + while (!lazy.empty()) { + merge(compare, list, lazy.pop()); + } // standard O(log n) optimum search method + + len = list.length; + + // there MUST be at least one + // non null element in this list + // we look for the first one + + for (j = 0; j < len - 1 && list[j] === null; ++j) {} + + // here j is necessarily < len + // and list[j] is non null + + i = j; + opt = list[j].value; + + // we lookup remaining elements to see if there + // is not a better candidate + + for (++j; j < len; ++j) { + + item = list[j]; + + if (item !== null) { + + candidate = item.value; + + if (compare(candidate, opt) < 0) { + + i = j; + opt = candidate; + } + } + } + + orphan = list[i].children; + list[i] = null; + + // we just removed the ith element + // if list[i] is the last cell + // of list we can drop it + + if (i === len - 1) { + list.pop(); + } + + // we store the children in the + // lazy list + + lazy.push(orphan); + + return opt; + }; + + var Heap = function Heap(compare) { + + // the compare function to use to compare values + + this.compare = compare; + + // number of elements in this heap + + this.length = 0; + + // list of binomial trees + + this.list = []; + + // list of binomial heaps waiting to be merged + + this.lazy = new _LazyStack2.default(); + }; + + Heap.prototype.pop = function () { + + if (this.length === 0) { + return undefined; + } + + --this.length; + + return lazy_binomial_heap_pop(this.compare, this.list, this.lazy); + }; + + Heap.prototype.push = function (value) { + + ++this.length; + + // push a new tree of rank 0 + + return lazy_binomial_heap_push(this.lazy, new BinomialTree(value, []), 0); + }; + + Heap.prototype.merge = function (other) { + + this.lazy.meld(other.lazy); + + this.length += other.length; + + return this; + }; + + return Heap; +} +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9MYXp5Qmlub21pYWxIZWFwLmpzIl0sIm5hbWVzIjpbIkxhenlCaW5vbWlhbEhlYXAiLCJCaW5vbWlhbFRyZWUiLCJsYXp5X2Jpbm9taWFsX2hlYXBfcHVzaCIsImxhenkiLCJ0cmVlIiwicmFuayIsImkiLCJzZXF1ZW5jZSIsInB1c2giLCJtZXJnZSIsImNvbXBhcmUiLCJsaXN0Iiwib3RoZXIiLCJsZW4iLCJjYXJyeSIsImxlbmd0aCIsImxhenlfYmlub21pYWxfaGVhcF9wb3AiLCJqIiwib3B0IiwiaXRlbSIsImNhbmRpZGF0ZSIsIm9ycGhhbiIsImVtcHR5IiwicG9wIiwidmFsdWUiLCJjaGlsZHJlbiIsIkhlYXAiLCJwcm90b3R5cGUiLCJ1bmRlZmluZWQiLCJtZWxkIl0sIm1hcHBpbmdzIjoiOzs7OztrQkFFd0JBLGdCOztBQUZ4Qjs7Ozs7O0FBRWUsU0FBU0EsZ0JBQVQsQ0FBNEJDLFlBQTVCLEVBQTJDOztBQUV6RCxLQUFJQywwQkFBMEIsU0FBMUJBLHVCQUEwQixDQUFVQyxJQUFWLEVBQWdCQyxJQUFoQixFQUFzQkMsSUFBd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RcdHRoaXMubGVuZ3RoICs9IG90aGVyLmxlbmd0aCA7XG5cblx0XHRyZXR1cm4gdGhpcyA7XG5cdH07XG5cblx0cmV0dXJuIEhlYXA7XG59XG4iXX0= \ No newline at end of file diff --git a/lib/LazyNode.js b/lib/LazyNode.js new file mode 100644 index 0000000..ab65a67 --- /dev/null +++ b/lib/LazyNode.js @@ -0,0 +1,12 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = LazyNode; +function LazyNode(value, next) { + + this.value = value; + this.next = next; +} +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9MYXp5Tm9kZS5qcyJdLCJuYW1lcyI6WyJMYXp5Tm9kZSIsInZhbHVlIiwibmV4dCJdLCJtYXBwaW5ncyI6Ijs7Ozs7a0JBQ3dCQSxRO0FBQVQsU0FBU0EsUUFBVCxDQUFvQkMsS0FBcEIsRUFBNEJDLElBQTVCLEVBQW1DOztBQUVqRCxNQUFLRCxLQUFMLEdBQWFBLEtBQWI7QUFDQSxNQUFLQyxJQUFMLEdBQVlBLElBQVo7QUFFQSIsImZpbGUiOiJMYXp5Tm9kZS5qcyIsInNvdXJjZXNDb250ZW50IjpbIlxuZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gTGF6eU5vZGUgKCB2YWx1ZSAsIG5leHQgKSB7XG5cblx0dGhpcy52YWx1ZSA9IHZhbHVlIDtcblx0dGhpcy5uZXh0ID0gbmV4dCA7XG5cbn1cbiJdfQ== \ No newline at end of file diff --git a/lib/LazyStack.js b/lib/LazyStack.js new file mode 100644 index 0000000..e70ce95 --- /dev/null +++ b/lib/LazyStack.js @@ -0,0 +1,60 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = LazyStack; + +var _LazyNode = require('./LazyNode'); + +var _LazyNode2 = _interopRequireDefault(_LazyNode); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * LazyStack#peek only valid if LazyStack#empty is false. + * LazyStack#shift only valid if LazyStack#empty is false. + */ + +function LazyStack() { + + this.top = null; + this.bottom = null; +} + +LazyStack.prototype.empty = function () { + + return this.top === null; +}; + +LazyStack.prototype.push = function (value) { + + this.top = new _LazyNode2.default(value, this.top); + + if (this.bottom === null) this.bottom = this.top; +}; + +/** + * Only valid if LazyStack#empty is false. + */ + +LazyStack.prototype.pop = function () { + + var value; + + value = this.top.value; + + this.top = this.top.next; + + if (this.top === null) this.bottom = null; + + return value; +}; + +LazyStack.prototype.meld = function (other) { + + if (this.bottom === null) this.top = other.top;else this.bottom.next = other.top; + + this.bottom = other.bottom; +}; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9MYXp5U3RhY2suanMiXSwibmFtZXMiOlsiTGF6eVN0YWNrIiwidG9wIiwiYm90dG9tIiwicHJvdG90eXBlIiwiZW1wdHkiLCJwdXNoIiwidmFsdWUiLCJwb3AiLCJuZXh0IiwibWVsZCIsIm90aGVyIl0sIm1hcHBpbmdzIjoiOzs7OztrQkFPd0JBLFM7O0FBUHhCOzs7Ozs7QUFFQTs7Ozs7QUFLZSxTQUFTQSxTQUFULEdBQXVCOztBQUVyQyxNQUFLQyxHQUFMLEdBQVcsSUFBWDtBQUNBLE1BQUtDLE1BQUwsR0FBYyxJQUFkO0FBRUE7O0FBRURGLFVBQVVHLFNBQVYsQ0FBb0JDLEtBQXBCLEdBQTRCLFlBQWE7O0FBRXhDLFFBQU8sS0FBS0gsR0FBTCxLQUFhLElBQXBCO0FBRUEsQ0FKRDs7QUFNQUQsVUFBVUcsU0FBVixDQUFvQkUsSUFBcEIsR0FBMkIsVUFBV0MsS0FBWCxFQUFtQjs7QUFHN0MsTUFBS0wsR0FBTCxHQUFXLHVCQUFjSyxLQUFkLEVBQXNCLEtBQUtMLEdBQTNCLENBQVg7O0FBRUEsS0FBSyxLQUFLQyxNQUFMLEtBQ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RoaXMuYm90dG9tID0gbnVsbCA7XG5cbn1cblxuTGF6eVN0YWNrLnByb3RvdHlwZS5lbXB0eSA9IGZ1bmN0aW9uICggKSB7XG5cblx0cmV0dXJuIHRoaXMudG9wID09PSBudWxsIDtcblxufSA7XG5cbkxhenlTdGFjay5wcm90b3R5cGUucHVzaCA9IGZ1bmN0aW9uICggdmFsdWUgKSB7XG5cblxuXHR0aGlzLnRvcCA9IG5ldyBMYXp5Tm9kZSggdmFsdWUgLCB0aGlzLnRvcCApIDtcblxuXHRpZiAoIHRoaXMuYm90dG9tID09PSBudWxsICkgdGhpcy5ib3R0b20gPSB0aGlzLnRvcCA7XG5cbn0gO1xuXG4vKipcbiAqIE9ubHkgdmFsaWQgaWYgTGF6eVN0YWNrI2VtcHR5IGlzIGZhbHNlLlxuICovXG5cbkxhenlTdGFjay5wcm90b3R5cGUucG9wID0gZnVuY3Rpb24gKCApIHtcblxuXHR2YXIgdmFsdWUgO1xuXG5cdHZhbHVlID0gdGhpcy50b3AudmFsdWUgO1xuXG5cdHRoaXMudG9wID0gdGhpcy50b3AubmV4dCA7XG5cblx0aWYgKCB0aGlzLnRvcCA9PT0gbnVsbCApIHRoaXMuYm90dG9tID0gbnVsbCA7XG5cblx0cmV0dXJuIHZhbHVlIDtcblxufSA7XG5cbkxhenlTdGFjay5wcm90b3R5cGUubWVsZCA9IGZ1bmN0aW9uICggb3RoZXIgKSB7XG5cblx0aWYgKCB0aGlzLmJvdHRvbSA9PT0gbnVsbCApIHRoaXMudG9wID0gb3RoZXIudG9wIDtcblxuXHRlbHNlIHRoaXMuYm90dG9tLm5leHQgPSBvdGhlci50b3AgO1xuXG5cdHRoaXMuYm90dG9tID0gb3RoZXIuYm90dG9tIDtcblxufSA7XG4iXX0= \ No newline at end of file diff --git a/lib/index.js b/lib/index.js new file mode 100644 index 0000000..787acdd --- /dev/null +++ b/lib/index.js @@ -0,0 +1,48 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.LazyStack = exports.LazyNode = exports.LazyBinomialHeap = exports.BinomialTreeWithParent = exports.BinomialTree = exports.BinomialHeap = undefined; + +var _BinomialHeap = require('./BinomialHeap'); + +var _BinomialHeap2 = _interopRequireDefault(_BinomialHeap); + +var _BinomialTree = require('./BinomialTree'); + +var _BinomialTree2 = _interopRequireDefault(_BinomialTree); + +var _BinomialTreeWithParent = require('./BinomialTreeWithParent'); + +var _BinomialTreeWithParent2 = _interopRequireDefault(_BinomialTreeWithParent); + +var _LazyBinomialHeap = require('./LazyBinomialHeap'); + +var _LazyBinomialHeap2 = _interopRequireDefault(_LazyBinomialHeap); + +var _LazyNode = require('./LazyNode'); + +var _LazyNode2 = _interopRequireDefault(_LazyNode); + +var _LazyStack = require('./LazyStack'); + +var _LazyStack2 = _interopRequireDefault(_LazyStack); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = { + BinomialHeap: _BinomialHeap2.default, + BinomialTree: _BinomialTree2.default, + BinomialTreeWithParent: _BinomialTreeWithParent2.default, + LazyBinomialHeap: _LazyBinomialHeap2.default, + LazyNode: _LazyNode2.default, + LazyStack: _LazyStack2.default +}; +exports.BinomialHeap = _BinomialHeap2.default; +exports.BinomialTree = _BinomialTree2.default; +exports.BinomialTreeWithParent = _BinomialTreeWithParent2.default; +exports.LazyBinomialHeap = _LazyBinomialHeap2.default; +exports.LazyNode = _LazyNode2.default; +exports.LazyStack = _LazyStack2.default; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJuYW1lcyI6WyJCaW5vbWlhbEhlYXAiLCJCaW5vbWlhbFRyZWUiLCJCaW5vbWlhbFRyZWVXaXRoUGFyZW50IiwiTGF6eUJpbm9taWFsSGVhcCIsIkxhenlOb2RlIiwiTGF6eVN0YWNrIl0sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBQUE7Ozs7QUFDQTs7OztBQUNBOzs7O0FBQ0E7Ozs7QUFDQTs7OztBQUNBOzs7Ozs7a0JBRWU7QUFDZEEscUNBRGM7QUFFZEMscUNBRmM7QUFHZEMseURBSGM7QUFJZEMsNkNBSmM7QUFLZEMsNkJBTGM7QUFNZEM7QUFOYyxDO1FBVWRMLFk7UUFDQUMsWTtRQUNBQyxzQjtRQUNBQyxnQjtRQUNBQyxRO1FBQ0FDLFMiLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgQmlub21pYWxIZWFwIGZyb20gJy4vQmlub21pYWxIZWFwJyA7XG5pbXBvcnQgQmlub21pYWxUcmVlIGZyb20gJy4vQmlub21pYWxUcmVlJyA7XG5pbXBvcnQgQmlub21pYWxUcmVlV2l0aFBhcmVudCBmcm9tICcuL0Jpbm9taWFsVHJlZVdpdGhQYXJlbnQnIDtcbmltcG9ydCBMYXp5Qmlub21pYWxIZWFwIGZyb20gJy4vTGF6eUJpbm9taWFsSGVhcCcgO1xuaW1wb3J0IExhenlOb2RlIGZyb20gJy4vTGF6eU5vZGUnIDtcbmltcG9ydCBMYXp5U3RhY2sgZnJvbSAnLi9MYXp5U3RhY2snIDtcblxuZXhwb3J0IGRlZmF1bHQge1xuXHRCaW5vbWlhbEhlYXAgLFxuXHRCaW5vbWlhbFRyZWUgLFxuXHRCaW5vbWlhbFRyZWVXaXRoUGFyZW50ICxcblx0TGF6eUJpbm9taWFsSGVhcCAsXG5cdExhenlOb2RlICxcblx0TGF6eVN0YWNrICxcbn0gO1xuXG5leHBvcnQge1xuXHRCaW5vbWlhbEhlYXAgLFxuXHRCaW5vbWlhbFRyZWUgLFxuXHRCaW5vbWlhbFRyZWVXaXRoUGFyZW50ICxcblx0TGF6eUJpbm9taWFsSGVhcCAsXG5cdExhenlOb2RlICxcblx0TGF6eVN0YWNrICxcbn0gO1xuIl19 \ No newline at end of file diff --git a/package.json b/package.json index d88f820..13276a0 100644 --- a/package.json +++ b/package.json @@ -1,37 +1,61 @@ { - "name": "aureooms-js-binomial-heap", - "description": "Binomial heap code bricks for JavaScript", - "homepage": "http://aureooms.github.io/js-binomial-heap/", - "main": "js/dist/binomial-heap.js", - "version": "10.0.1", - "repository": { - "url": "https://github.com/aureooms/js-binomial-heap.git", - "type": "git" - }, - "keywords": [ - "binomial", - "bricks", - "ender", - "heap", - "javascript", - "js" - ], - "scripts": { - "build": "./node_modules/.bin/aureooms-node-package-build", - "test": "./node_modules/.bin/aureooms-node-package-test", - "doc": "./node_modules/.bin/groc" - }, - "author": "aureooms", - "devDependencies": { - "aureooms-js-heap-spec": "^8.0.0", - "aureooms-node-package": "^6.0.1" - }, - "bugs": { - "url": "https://github.com/aureooms/js-binomial-heap/issues" - }, - "dependencies": {}, - "license": "AGPL-3.0", - "spm": { - "main": "js/dist/binomial-heap.js" - } -} \ No newline at end of file + "name": "aureooms-js-binomial-heap", + "description": "Binomial heap data structures for JavaScript", + "version": "10.0.1", + "author": "Aurélien Ooms ", + "ava": { + "require": [ + "babel-polyfill", + "babel-register" + ] + }, + "babel": { + "presets": [ + "latest" + ], + "env": { + "development": { + "sourceMaps": "inline" + } + } + }, + "bugs": { + "url": "https://github.com/aureooms/js-binomial-heap/issues" + }, + "dependencies": {}, + "devDependencies": { + "aureooms-js-array": "^3.1.0", + "aureooms-js-functools": "^2.0.3", + "aureooms-js-heap-spec": "^10.0.1", + "aureooms-js-itertools": "^3.1.1", + "ava": "^0.17.0", + "babel-cli": "^6.18.0", + "babel-polyfill": "^6.20.0", + "babel-preset-latest": "^6.16.0", + "codeclimate-test-reporter": "^0.4.0", + "coveralls": "^2.11.15", + "esdoc": "^0.5.2", + "nyc": "^10.1.2" + }, + "homepage": "http://aureooms.github.io/js-binomial-heap/", + "keywords": [ + "binomial", + "data", + "heap", + "javascript", + "js", + "structure" + ], + "license": "AGPL-3.0", + "main": "lib/index.js", + "repository": { + "url": "https://github.com/aureooms/js-binomial-heap.git", + "type": "git" + }, + "scripts": { + "build": "babel src -d lib", + "cover": "nyc --reporter=lcov npm test", + "prepublish": "npm run build", + "test": "ava ./test/src --concurrency 8" + } +} diff --git a/pkg.json b/pkg.json deleted file mode 100644 index 1ceeeea..0000000 --- a/pkg.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "binomial-heap", - "code": { - "main": [ - "js", - "dist", - "binomial-heap.js" - ], - "test": [ - "test", - "js" - ] - }, - "src": "js/src/", - "debug": false, - "out": "js/dist/", - "babel": true -} \ No newline at end of file diff --git a/js/src/BinomialHeap.js b/src/BinomialHeap.js similarity index 99% rename from js/src/BinomialHeap.js rename to src/BinomialHeap.js index 32b62a8..a5f5afc 100644 --- a/js/src/BinomialHeap.js +++ b/src/BinomialHeap.js @@ -1,4 +1,4 @@ -var BinomialHeap = function ( BinomialTree ) { +export default function BinomialHeap ( BinomialTree ) { var binomial_heap_push = function ( compare, list, tree, rank ) { @@ -515,6 +515,4 @@ var BinomialHeap = function ( BinomialTree ) { return Heap; -}; - -exports.BinomialHeap = BinomialHeap; +} diff --git a/js/src/BinomialTree.js b/src/BinomialTree.js similarity index 89% rename from js/src/BinomialTree.js rename to src/BinomialTree.js index 36f5fc6..81a0b8a 100644 --- a/js/src/BinomialTree.js +++ b/src/BinomialTree.js @@ -1,9 +1,9 @@ -var BinomialTree = function ( value, children ) { +export default function BinomialTree ( value, children ) { this.value = value; this.children = children; -}; +} /** * /!\ Can only be used to merge two trees of the same rank. @@ -38,5 +38,3 @@ BinomialTree.prototype.detach = function () { BinomialTree.prototype.setparent = function ( parent ) { // we do not keep track of any parent here }; - -exports.BinomialTree = BinomialTree; diff --git a/js/src/BinomialTreeWithParent.js b/src/BinomialTreeWithParent.js similarity index 88% rename from js/src/BinomialTreeWithParent.js rename to src/BinomialTreeWithParent.js index b1302a4..fbab462 100644 --- a/js/src/BinomialTreeWithParent.js +++ b/src/BinomialTreeWithParent.js @@ -1,10 +1,10 @@ -var BinomialTreeWithParent = function ( value, children ) { +export default function BinomialTreeWithParent ( value, children ) { this.value = value; this.children = children; this.parent = null; -}; +} BinomialTreeWithParent.prototype.rank = function () { return this.children.length; @@ -46,5 +46,3 @@ BinomialTreeWithParent.prototype.detach = function () { BinomialTreeWithParent.prototype.setparent = function ( parent ) { this.parent = parent; }; - -exports.BinomialTreeWithParent = BinomialTreeWithParent; diff --git a/js/src/LazyBinomialHeap.js b/src/LazyBinomialHeap.js similarity index 97% rename from js/src/LazyBinomialHeap.js rename to src/LazyBinomialHeap.js index 6d3e379..c3c7b5f 100644 --- a/js/src/LazyBinomialHeap.js +++ b/src/LazyBinomialHeap.js @@ -1,5 +1,6 @@ +import LazyStack from './LazyStack' ; -var LazyBinomialHeap = function ( BinomialTree ) { +export default function LazyBinomialHeap ( BinomialTree ) { var lazy_binomial_heap_push = function( lazy, tree, rank ){ @@ -266,6 +267,4 @@ var LazyBinomialHeap = function ( BinomialTree ) { }; return Heap; -}; - -exports.LazyBinomialHeap = LazyBinomialHeap; +} diff --git a/src/LazyNode.js b/src/LazyNode.js new file mode 100644 index 0000000..e1b56a4 --- /dev/null +++ b/src/LazyNode.js @@ -0,0 +1,7 @@ + +export default function LazyNode ( value , next ) { + + this.value = value ; + this.next = next ; + +} diff --git a/js/src/LazyList.js b/src/LazyStack.js similarity index 91% rename from js/src/LazyList.js rename to src/LazyStack.js index 5b2b62d..8ff0fa8 100644 --- a/js/src/LazyList.js +++ b/src/LazyStack.js @@ -1,16 +1,16 @@ - +import LazyNode from './LazyNode' ; /** * LazyStack#peek only valid if LazyStack#empty is false. * LazyStack#shift only valid if LazyStack#empty is false. */ -var LazyStack = function ( ) { +export default function LazyStack ( ) { this.top = null ; this.bottom = null ; -} ; +} LazyStack.prototype.empty = function ( ) { @@ -54,5 +54,3 @@ LazyStack.prototype.meld = function ( other ) { this.bottom = other.bottom ; } ; - -exports.LazyStack = LazyStack ; diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..61ab456 --- /dev/null +++ b/src/index.js @@ -0,0 +1,24 @@ +import BinomialHeap from './BinomialHeap' ; +import BinomialTree from './BinomialTree' ; +import BinomialTreeWithParent from './BinomialTreeWithParent' ; +import LazyBinomialHeap from './LazyBinomialHeap' ; +import LazyNode from './LazyNode' ; +import LazyStack from './LazyStack' ; + +export default { + BinomialHeap , + BinomialTree , + BinomialTreeWithParent , + LazyBinomialHeap , + LazyNode , + LazyStack , +} ; + +export { + BinomialHeap , + BinomialTree , + BinomialTreeWithParent , + LazyBinomialHeap , + LazyNode , + LazyStack , +} ; diff --git a/test/js/index.js b/test/js/index.js deleted file mode 100644 index 869a49d..0000000 --- a/test/js/index.js +++ /dev/null @@ -1,10 +0,0 @@ -var pkg = require('aureooms-node-package'); - - -var opt = { - src : __dirname + '/src/', - exports : module.exports, - base : 0 -}; - -pkg.include(opt); diff --git a/test/js/src/all.js b/test/js/src/all.js deleted file mode 100644 index e43db49..0000000 --- a/test/js/src/all.js +++ /dev/null @@ -1,42 +0,0 @@ - -var heapspec = require( "aureooms-js-heap-spec" ) ; - -var heapswithreferences = [ - - - [ "BinomialHeap, BinomialTreeWithParent" , function ( compare ) { - - return new ( binomialheap.BinomialHeap( binomialheap.BinomialTreeWithParent ) )( compare ) ; - - } ] , - - -] ; - -var heapswithoutreferences = [ - - [ "BinomialHeap, BinomialTree" , function ( compare ) { - - return new ( binomialheap.BinomialHeap( binomialheap.BinomialTree ) )( compare ) ; - - } ] , -] ; - -var lazyheaps = [ - - [ "LazyBinomialHeap, BinomialTree" , function ( compare ) { - - return new ( binomialheap.LazyBinomialHeap( binomialheap.BinomialTree ) )( compare ) ; - - } ] , - [ "LazyBinomialHeap, BinomialTreeWithParent" , function ( compare ) { - - return new ( binomialheap.LazyBinomialHeap( binomialheap.BinomialTreeWithParent ) )( compare ) ; - - } ] -] ; - -heapspec.test( heapswithreferences , true ) ; -heapspec.test( heapswithoutreferences , false ) ; -heapspec.pushpop( lazyheaps ) ; -heapspec.merge( lazyheaps ) ; diff --git a/test/src/spec.js b/test/src/spec.js new file mode 100644 index 0000000..59f98e0 --- /dev/null +++ b/test/src/spec.js @@ -0,0 +1,50 @@ +import ava from 'ava' ; + +import * as spec from 'aureooms-js-heap-spec' ; + +import { + BinomialHeap, + BinomialTreeWithParent, + BinomialTree, + LazyBinomialHeap, +} from '../../src' ; + +const heapswithreferences = [ + + + [ "BinomialHeap, BinomialTreeWithParent" , function ( compare ) { + + return new ( BinomialHeap( BinomialTreeWithParent ) )( compare ) ; + + } ] , + + +] ; + +const heapswithoutreferences = [ + + [ "BinomialHeap, BinomialTree" , function ( compare ) { + + return new ( BinomialHeap( BinomialTree ) )( compare ) ; + + } ] , +] ; + +const lazyheaps = [ + + [ "LazyBinomialHeap, BinomialTree" , function ( compare ) { + + return new ( LazyBinomialHeap( BinomialTree ) )( compare ) ; + + } ] , + [ "LazyBinomialHeap, BinomialTreeWithParent" , function ( compare ) { + + return new ( LazyBinomialHeap( BinomialTreeWithParent ) )( compare ) ; + + } ] +] ; + +spec.test( ava , heapswithreferences , { references : true , length : true } ) ; +spec.test( ava , heapswithoutreferences , { references : false , length : true } ) ; +spec.pushpop( ava , true , lazyheaps ) ; +spec.merge( ava , true , lazyheaps ) ; From d1c4546ce00d0818f85438b3b910f5024b7c67f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Ooms?= Date: Wed, 18 Jan 2017 19:44:26 +0100 Subject: [PATCH 2/3] esdoc does not support ava --- esdoc.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/esdoc.json b/esdoc.json index f2645d6..eaf839a 100644 --- a/esdoc.json +++ b/esdoc.json @@ -10,10 +10,6 @@ "index": "./README.md", "package": "./package.json", "title": "aureooms/js-binomial-heap", - "test": { - "type": "ava", - "source": "./test/src" - }, "manual": { "overview": [ "./doc/manual/overview.md" From 403371b2a13fa97270ebdfee56c31aa32c2bee1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Ooms?= Date: Wed, 18 Jan 2017 19:44:58 +0100 Subject: [PATCH 3/3] 11.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 13276a0..496dea7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "aureooms-js-binomial-heap", "description": "Binomial heap data structures for JavaScript", - "version": "10.0.1", + "version": "11.0.0", "author": "Aurélien Ooms ", "ava": { "require": [