ekylibre-cartography 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +3 -0
  3. data/Rakefile +10 -0
  4. data/app/assets/javascripts/cartography.coffee +535 -0
  5. data/app/assets/javascripts/cartography/base.coffee +11 -0
  6. data/app/assets/javascripts/cartography/controls.coffee +463 -0
  7. data/app/assets/javascripts/cartography/events.coffee +36 -0
  8. data/app/assets/javascripts/cartography/layers.coffee +127 -0
  9. data/app/assets/javascripts/cartography/layers/simple.coffee +37 -0
  10. data/app/assets/javascripts/cartography/leaflet/controls.coffee +420 -0
  11. data/app/assets/javascripts/cartography/leaflet/handlers.coffee +461 -0
  12. data/app/assets/javascripts/cartography/leaflet/i18n.coffee +31 -0
  13. data/app/assets/javascripts/cartography/leaflet/layers.coffee +60 -0
  14. data/app/assets/javascripts/cartography/leaflet/toolbars.coffee +450 -0
  15. data/app/assets/javascripts/cartography/patches.js +8 -0
  16. data/app/assets/javascripts/cartography/util.coffee +18 -0
  17. data/app/assets/javascripts/main.js +18 -0
  18. data/app/assets/stylesheets/cartography.css +86 -0
  19. data/app/helpers/cartography_helper.rb +55 -0
  20. data/lib/cartography.rb +1 -0
  21. data/lib/cartography/engine.rb +11 -0
  22. data/lib/cartography/version.rb +3 -0
  23. data/vendor/assets/components/d3-array/dist/d3-array.js +590 -0
  24. data/vendor/assets/components/d3-array/dist/d3-array.min.js +2 -0
  25. data/vendor/assets/components/geojson-equality/dist/geojson-equality.js +295 -0
  26. data/vendor/assets/components/geojson-equality/dist/geojson-equality.js.map +21 -0
  27. data/vendor/assets/components/geojson-equality/dist/geojson-equality.min.js +1 -0
  28. data/vendor/assets/components/leaflet-controlpanel/dist/leaflet.controlpanel.css +29 -0
  29. data/vendor/assets/components/leaflet-controlpanel/dist/leaflet.controlpanel.js +269 -0
  30. data/vendor/assets/components/leaflet-draw-cut/dist/leaflet.draw.cut.css +1 -0
  31. data/vendor/assets/components/leaflet-draw-cut/dist/leaflet.draw.cut.js +8 -0
  32. data/vendor/assets/components/leaflet-draw-merge/dist/leaflet.draw.merge.css +0 -0
  33. data/vendor/assets/components/leaflet-draw-merge/dist/leaflet.draw.merge.js +48026 -0
  34. data/vendor/assets/components/leaflet-draw/dist/leaflet.draw-src.css +326 -0
  35. data/vendor/assets/components/leaflet-draw/dist/leaflet.draw-src.js +4653 -0
  36. data/vendor/assets/components/leaflet-draw/dist/leaflet.draw-src.map +1 -0
  37. data/vendor/assets/components/leaflet-draw/dist/leaflet.draw.css +10 -0
  38. data/vendor/assets/components/leaflet-draw/dist/leaflet.draw.js +10 -0
  39. data/vendor/assets/components/leaflet-geographicutil/dist/leaflet.geographicutil.js +3220 -0
  40. data/vendor/assets/components/leaflet-reactive_measure/dist/reactive_measure.css +30 -0
  41. data/vendor/assets/components/leaflet-reactive_measure/dist/reactive_measure.js +3764 -0
  42. data/vendor/assets/components/leaflet/dist/leaflet-src.js +13609 -0
  43. data/vendor/assets/components/leaflet/dist/leaflet-src.js.map +1 -0
  44. data/vendor/assets/components/leaflet/dist/leaflet-src.map +1 -0
  45. data/vendor/assets/components/leaflet/dist/leaflet.css +632 -0
  46. data/vendor/assets/components/leaflet/dist/leaflet.js +5 -0
  47. data/vendor/assets/components/leaflet/dist/leaflet.js.map +1 -0
  48. data/vendor/assets/components/martinez-polygon-clipping/dist/martinez.min.js +9 -0
  49. data/vendor/assets/components/martinez-polygon-clipping/dist/martinez.umd.js +1716 -0
  50. data/vendor/assets/components/martinez-polygon-clipping/dist/martinez.umd.js.map +1 -0
  51. data/vendor/assets/components/polygon-clipping/dist/polygon-clipping.js +279 -0
  52. data/vendor/assets/components/polygon-clipping/dist/polygon-clipping.min.js +1 -0
  53. data/vendor/assets/components/rtree/dist/rtree.js +911 -0
  54. data/vendor/assets/components/rtree/dist/rtree.min.js +1 -0
  55. data/vendor/assets/components/splaytree/dist/splay.es6.js +765 -0
  56. data/vendor/assets/components/splaytree/dist/splay.es6.js.map +1 -0
  57. data/vendor/assets/components/splaytree/dist/splay.js +797 -0
  58. data/vendor/assets/components/splaytree/dist/splay.js.map +1 -0
  59. metadata +156 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"splay.es6.js","sources":["../index.js"],"sourcesContent":["function DEFAULT_COMPARE (a, b) { return a > b ? 1 : a < b ? -1 : 0; }\n\nexport default class SplayTree {\n\n constructor(compare = DEFAULT_COMPARE, noDuplicates = false) {\n this._compare = compare;\n this._root = null;\n this._size = 0;\n this._noDuplicates = !!noDuplicates;\n }\n\n\n rotateLeft(x) {\n var y = x.right;\n if (y) {\n x.right = y.left;\n if (y.left) y.left.parent = x;\n y.parent = x.parent;\n }\n\n if (!x.parent) this._root = y;\n else if (x === x.parent.left) x.parent.left = y;\n else x.parent.right = y;\n if (y) y.left = x;\n x.parent = y;\n }\n\n\n rotateRight(x) {\n var y = x.left;\n if (y) {\n x.left = y.right;\n if (y.right) y.right.parent = x;\n y.parent = x.parent;\n }\n\n if (!x.parent) this._root = y;\n else if(x === x.parent.left) x.parent.left = y;\n else x.parent.right = y;\n if (y) y.right = x;\n x.parent = y;\n }\n\n\n _splay(x) {\n while (x.parent) {\n var p = x.parent;\n if (!p.parent) {\n if (p.left === x) this.rotateRight(p);\n else this.rotateLeft(p);\n } else if (p.left === x && p.parent.left === p) {\n this.rotateRight(p.parent);\n this.rotateRight(p);\n } else if (p.right === x && p.parent.right === p) {\n this.rotateLeft(p.parent);\n this.rotateLeft(p);\n } else if (p.left === x && p.parent.right === p) {\n this.rotateRight(p);\n this.rotateLeft(p);\n } else {\n this.rotateLeft(p);\n this.rotateRight(p);\n }\n }\n }\n\n\n splay(x) {\n var p, gp, ggp, l, r;\n\n while (x.parent) {\n p = x.parent;\n gp = p.parent;\n\n if (gp && gp.parent) {\n ggp = gp.parent;\n if (ggp.left === gp) ggp.left = x;\n else ggp.right = x;\n x.parent = ggp;\n } else {\n x.parent = null;\n this._root = x;\n }\n\n l = x.left; r = x.right;\n\n if (x === p.left) { // left\n if (gp) {\n if (gp.left === p) {\n /* zig-zig */\n if (p.right) {\n gp.left = p.right;\n gp.left.parent = gp;\n } else gp.left = null;\n\n p.right = gp;\n gp.parent = p;\n } else {\n /* zig-zag */\n if (l) {\n gp.right = l;\n l.parent = gp;\n } else gp.right = null;\n\n x.left = gp;\n gp.parent = x;\n }\n }\n if (r) {\n p.left = r;\n r.parent = p;\n } else p.left = null;\n\n x.right = p;\n p.parent = x;\n } else { // right\n if (gp) {\n if (gp.right === p) {\n /* zig-zig */\n if (p.left) {\n gp.right = p.left;\n gp.right.parent = gp;\n } else gp.right = null;\n\n p.left = gp;\n gp.parent = p;\n } else {\n /* zig-zag */\n if (r) {\n gp.left = r;\n r.parent = gp;\n } else gp.left = null;\n\n x.right = gp;\n gp.parent = x;\n }\n }\n if (l) {\n p.right = l;\n l.parent = p;\n } else p.right = null;\n\n x.left = p;\n p.parent = x;\n }\n }\n }\n\n\n replace(u, v) {\n if (!u.parent) this._root = v;\n else if (u === u.parent.left) u.parent.left = v;\n else u.parent.right = v;\n if (v) v.parent = u.parent;\n }\n\n\n minNode(u = this._root) {\n if (u) while (u.left) u = u.left;\n return u;\n }\n\n\n maxNode(u = this._root) {\n if (u) while (u.right) u = u.right;\n return u;\n }\n\n\n insert(key, data) {\n var z = this._root;\n var p = null;\n var comp = this._compare;\n var cmp;\n\n if (this._noDuplicates) {\n while (z) {\n p = z;\n cmp = comp(z.key, key);\n if (cmp === 0) return;\n else if (comp(z.key, key) < 0) z = z.right;\n else z = z.left;\n }\n } else {\n while (z) {\n p = z;\n if (comp(z.key, key) < 0) z = z.right;\n else z = z.left;\n }\n }\n\n z = { key, data, left: null, right: null, parent: p };\n\n if (!p) this._root = z;\n else if (comp(p.key, z.key) < 0) p.right = z;\n else p.left = z;\n\n this.splay(z);\n this._size++;\n return z;\n }\n\n\n find (key) {\n var z = this._root;\n var comp = this._compare;\n while (z) {\n var cmp = comp(z.key, key);\n if (cmp < 0) z = z.right;\n else if (cmp > 0) z = z.left;\n else return z;\n }\n return null;\n }\n\n /**\n * Whether the tree contains a node with the given key\n * @param {Key} key\n * @return {boolean} true/false\n */\n contains (key) {\n var node = this._root;\n var comparator = this._compare;\n while (node) {\n var cmp = comparator(key, node.key);\n if (cmp === 0) return true;\n else if (cmp < 0) node = node.left;\n else node = node.right;\n }\n\n return false;\n }\n\n\n remove (key) {\n var z = this.find(key);\n\n if (!z) return false;\n\n this.splay(z);\n\n if (!z.left) this.replace(z, z.right);\n else if (!z.right) this.replace(z, z.left);\n else {\n var y = this.minNode(z.right);\n if (y.parent !== z) {\n this.replace(y, y.right);\n y.right = z.right;\n y.right.parent = y;\n }\n this.replace(z, y);\n y.left = z.left;\n y.left.parent = y;\n }\n\n this._size--;\n return true;\n }\n\n\n removeNode(z) {\n if (!z) return false;\n\n this.splay(z);\n\n if (!z.left) this.replace(z, z.right);\n else if (!z.right) this.replace(z, z.left);\n else {\n var y = this.minNode(z.right);\n if (y.parent !== z) {\n this.replace(y, y.right);\n y.right = z.right;\n y.right.parent = y;\n }\n this.replace(z, y);\n y.left = z.left;\n y.left.parent = y;\n }\n\n this._size--;\n return true;\n }\n\n\n erase (key) {\n var z = this.find(key);\n if (!z) return;\n\n this.splay(z);\n\n var s = z.left;\n var t = z.right;\n\n var sMax = null;\n if (s) {\n s.parent = null;\n sMax = this.maxNode(s);\n this.splay(sMax);\n this._root = sMax;\n }\n if (t) {\n if (s) sMax.right = t;\n else this._root = t;\n t.parent = sMax;\n }\n\n this._size--;\n }\n\n /**\n * Removes and returns the node with smallest key\n * @return {?Node}\n */\n pop () {\n var node = this._root, returnValue = null;\n if (node) {\n while (node.left) node = node.left;\n returnValue = { key: node.key, data: node.data };\n this.remove(node.key);\n }\n return returnValue;\n }\n\n\n /* eslint-disable class-methods-use-this */\n\n /**\n * Successor node\n * @param {Node} node\n * @return {?Node}\n */\n next (node) {\n var successor = node;\n if (successor) {\n if (successor.right) {\n successor = successor.right;\n while (successor && successor.left) successor = successor.left;\n } else {\n successor = node.parent;\n while (successor && successor.right === node) {\n node = successor; successor = successor.parent;\n }\n }\n }\n return successor;\n }\n\n\n /**\n * Predecessor node\n * @param {Node} node\n * @return {?Node}\n */\n prev (node) {\n var predecessor = node;\n if (predecessor) {\n if (predecessor.left) {\n predecessor = predecessor.left;\n while (predecessor && predecessor.right) predecessor = predecessor.right;\n } else {\n predecessor = node.parent;\n while (predecessor && predecessor.left === node) {\n node = predecessor;\n predecessor = predecessor.parent;\n }\n }\n }\n return predecessor;\n }\n /* eslint-enable class-methods-use-this */\n\n\n /**\n * @param {forEachCallback} callback\n * @return {SplayTree}\n */\n forEach(callback) {\n var current = this._root;\n var s = [], done = false, i = 0;\n\n while (!done) {\n // Reach the left most Node of the current Node\n if (current) {\n // Place pointer to a tree node on the stack\n // before traversing the node's left subtree\n s.push(current);\n current = current.left;\n } else {\n // BackTrack from the empty subtree and visit the Node\n // at the top of the stack; however, if the stack is\n // empty you are done\n if (s.length > 0) {\n current = s.pop();\n callback(current, i++);\n\n // We have visited the node and its left\n // subtree. Now, it's right subtree's turn\n current = current.right;\n } else done = true;\n }\n }\n return this;\n }\n\n\n /**\n * Walk key range from `low` to `high`. Stops if `fn` returns a value.\n * @param {Key} low\n * @param {Key} high\n * @param {Function} fn\n * @param {*?} ctx\n * @return {SplayTree}\n */\n range(low, high, fn, ctx) {\n const Q = [];\n const compare = this._compare;\n let node = this._root, cmp;\n\n while (Q.length !== 0 || node) {\n if (node) {\n Q.push(node);\n node = node.left;\n } else {\n node = Q.pop();\n cmp = compare(node.key, high);\n if (cmp > 0) {\n break;\n } else if (compare(node.key, low) >= 0) {\n if (fn.call(ctx, node)) return this; // stop if smth is returned\n }\n node = node.right;\n }\n }\n return this;\n }\n\n /**\n * Returns all keys in order\n * @return {Array<Key>}\n */\n keys () {\n var current = this._root;\n var s = [], r = [], done = false;\n\n while (!done) {\n if (current) {\n s.push(current);\n current = current.left;\n } else {\n if (s.length > 0) {\n current = s.pop();\n r.push(current.key);\n current = current.right;\n } else done = true;\n }\n }\n return r;\n }\n\n\n /**\n * Returns `data` fields of all nodes in order.\n * @return {Array<Value>}\n */\n values () {\n var current = this._root;\n var s = [], r = [], done = false;\n\n while (!done) {\n if (current) {\n s.push(current);\n current = current.left;\n } else {\n if (s.length > 0) {\n current = s.pop();\n r.push(current.data);\n current = current.right;\n } else done = true;\n }\n }\n return r;\n }\n\n\n /**\n * Returns node at given index\n * @param {number} index\n * @return {?Node}\n */\n at (index) {\n // removed after a consideration, more misleading than useful\n // index = index % this.size;\n // if (index < 0) index = this.size - index;\n\n var current = this._root;\n var s = [], done = false, i = 0;\n\n while (!done) {\n if (current) {\n s.push(current);\n current = current.left;\n } else {\n if (s.length > 0) {\n current = s.pop();\n if (i === index) return current;\n i++;\n current = current.right;\n } else done = true;\n }\n }\n return null;\n }\n\n /**\n * Bulk-load items. Both array have to be same size\n * @param {Array<Key>} keys\n * @param {Array<Value>} [values]\n * @param {Boolean} [presort=false] Pre-sort keys and values, using\n * tree's comparator. Sorting is done\n * in-place\n * @return {AVLTree}\n */\n load(keys = [], values = [], presort = false) {\n if (this._size !== 0) throw new Error('bulk-load: tree is not empty');\n const size = keys.length;\n if (presort) sort(keys, values, 0, size - 1, this._compare);\n this._root = loadRecursive(null, keys, values, 0, size);\n this._size = size;\n return this;\n }\n\n\n min() {\n var node = this.minNode(this._root);\n if (node) return node.key;\n else return null;\n }\n\n\n max() {\n var node = this.maxNode(this._root);\n if (node) return node.key;\n else return null;\n }\n\n isEmpty() { return this._root === null; }\n get size() { return this._size; }\n\n\n /**\n * Create a tree and load it with items\n * @param {Array<Key>} keys\n * @param {Array<Value>?} [values]\n\n * @param {Function?} [comparator]\n * @param {Boolean?} [presort=false] Pre-sort keys and values, using\n * tree's comparator. Sorting is done\n * in-place\n * @param {Boolean?} [noDuplicates=false] Allow duplicates\n * @return {SplayTree}\n */\n static createTree(keys, values, comparator, presort, noDuplicates) {\n return new SplayTree(comparator, noDuplicates).load(keys, values, presort);\n }\n}\n\n\nfunction loadRecursive (parent, keys, values, start, end) {\n const size = end - start;\n if (size > 0) {\n const middle = start + Math.floor(size / 2);\n const key = keys[middle];\n const data = values[middle];\n const node = { key, data, parent };\n node.left = loadRecursive(node, keys, values, start, middle);\n node.right = loadRecursive(node, keys, values, middle + 1, end);\n return node;\n }\n return null;\n}\n\n\nfunction sort(keys, values, left, right, compare) {\n if (left >= right) return;\n\n const pivot = keys[(left + right) >> 1];\n let i = left - 1;\n let j = right + 1;\n\n while (true) {\n do i++; while (compare(keys[i], pivot) < 0);\n do j--; while (compare(keys[j], pivot) > 0);\n if (i >= j) break;\n\n let tmp = keys[i];\n keys[i] = keys[j];\n keys[j] = tmp;\n\n tmp = values[i];\n values[i] = values[j];\n values[j] = tmp;\n }\n\n sort(keys, values, left, j, compare);\n sort(keys, values, j + 1, right, compare);\n}\n"],"names":[],"mappings":";;;;;;;;;AAAA,SAAS,eAAe,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE;;AAEtE,AAAe,MAAM,SAAS,CAAC;;EAE7B,WAAW,CAAC,OAAO,GAAG,eAAe,EAAE,YAAY,GAAG,KAAK,EAAE;IAC3D,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IAClB,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IACf,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC,YAAY,CAAC;GACrC;;;EAGD,UAAU,CAAC,CAAC,EAAE;IACZ,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC;IAChB,IAAI,CAAC,EAAE;MACL,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC;MACjB,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;MAC9B,CAAC,CA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AAG,CAAC,EAAE;IAC5C,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM;;IAElB,IAAI,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;;IAEd,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAChB,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACtB,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;GACjB;;EAED,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC;EAC1C,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;CAC3C;;;;"}
@@ -0,0 +1,797 @@
1
+ /**
2
+ * splaytree v2.0.2
3
+ * Fast Splay tree for Node and browser
4
+ *
5
+ * @author Alexander Milevski <info@w8r.name>
6
+ * @license MIT
7
+ * @preserve
8
+ */
9
+
10
+ (function (global, factory) {
11
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
12
+ typeof define === 'function' && define.amd ? define(factory) :
13
+ (global.SplayTree = factory());
14
+ }(this, (function () { 'use strict';
15
+
16
+ /* follows "An implementation of top-down splaying"
17
+ * by D. Sleator <sleator@cs.cmu.edu> March 1992
18
+ */
19
+
20
+ /**
21
+ * @typedef {*} Key
22
+ */
23
+
24
+
25
+ /**
26
+ * @typedef {*} Value
27
+ */
28
+
29
+
30
+ /**
31
+ * @typedef {function(node:Node):void} Visitor
32
+ */
33
+
34
+
35
+ /**
36
+ * @typedef {function(a:Key, b:Key):number} Comparator
37
+ */
38
+
39
+
40
+ /**
41
+ * @param {function(node:Node):string} NodePrinter
42
+ */
43
+
44
+
45
+ /**
46
+ * @typedef {Object} Node
47
+ * @property {Key} Key
48
+ * @property {Value=} data
49
+ * @property {Node} left
50
+ * @property {Node} right
51
+ */
52
+
53
+ var Node = function Node (key, data) {
54
+ this.key = key;
55
+ this.data = data;
56
+ this.left = null;
57
+ this.right= null;
58
+ };
59
+
60
+ function DEFAULT_COMPARE (a, b) { return a > b ? 1 : a < b ? -1 : 0; }
61
+
62
+
63
+ /**
64
+ * Simple top down splay, not requiring i to be in the tree t.
65
+ * @param {Key} i
66
+ * @param {Node?} t
67
+ * @param {Comparator} comparator
68
+ */
69
+ function splay (i, t, comparator) {
70
+ if (t === null) { return t; }
71
+ var l, r, y;
72
+ var N = new Node();
73
+ l = r = N;
74
+
75
+ while (true) {
76
+ var cmp = comparator(i, t.key);
77
+ //if (i < t.key) {
78
+ if (cmp < 0) {
79
+ if (t.left === null) { break; }
80
+ //if (i < t.left.key) {
81
+ if (comparator(i, t.left.key) < 0) {
82
+ y = t.left; /* rotate right */
83
+ t.left = y.right;
84
+ y.right = t;
85
+ t = y;
86
+ if (t.left === null) { break; }
87
+ }
88
+ r.left = t; /* link right */
89
+ r = t;
90
+ t = t.left;
91
+ //} else if (i > t.key) {
92
+ } else if (cmp > 0) {
93
+ if (t.right === null) { break; }
94
+ //if (i > t.right.key) {
95
+ if (comparator(i, t.right.key) > 0) {
96
+ y = t.right; /* rotate left */
97
+ t.right = y.left;
98
+ y.left = t;
99
+ t = y;
100
+ if (t.right === null) { break; }
101
+ }
102
+ l.right = t; /* link left */
103
+ l = t;
104
+ t = t.right;
105
+ } else {
106
+ break;
107
+ }
108
+ }
109
+ /* assemble */
110
+ l.right = t.left;
111
+ r.left = t.right;
112
+ t.left = N.right;
113
+ t.right = N.left;
114
+ return t;
115
+ }
116
+
117
+
118
+ /**
119
+ * @param {Key} i
120
+ * @param {Value} data
121
+ * @param {Comparator} comparator
122
+ * @param {Tree} tree
123
+ * @return {Node} root
124
+ */
125
+ function insert (i, data, t, comparator, tree) {
126
+ var node = new Node(i, data);
127
+
128
+ tree._size++;
129
+
130
+ if (t === null) {
131
+ node.left = node.right = null;
132
+ return node;
133
+ }
134
+
135
+ t = splay(i, t, comparator);
136
+ var cmp = comparator(i, t.key);
137
+ if (cmp < 0) {
138
+ node.left = t.left;
139
+ node.right = t;
140
+ t.left = null;
141
+ } else if (cmp >= 0) {
142
+ node.right = t.right;
143
+ node.left = t;
144
+ t.right = null;
145
+ }
146
+ return node;
147
+ }
148
+
149
+
150
+ /**
151
+ * Insert i into the tree t, unless it's already there.
152
+ * @param {Key} i
153
+ * @param {Value} data
154
+ * @param {Comparator} comparator
155
+ * @param {Tree} tree
156
+ * @return {Node} root
157
+ */
158
+ function add (i, data, t, comparator, tree) {
159
+ var node = new Node(i, data);
160
+
161
+ if (t === null) {
162
+ node.left = node.right = null;
163
+ tree._size++;
164
+ return node;
165
+ }
166
+
167
+ t = splay(i, t, comparator);
168
+ var cmp = comparator(i, t.key);
169
+ if (cmp === 0) { return t; }
170
+ else {
171
+ if (cmp < 0) {
172
+ node.left = t.left;
173
+ node.right = t;
174
+ t.left = null;
175
+ } else if (cmp > 0) {
176
+ node.right = t.right;
177
+ node.left = t;
178
+ t.right = null;
179
+ }
180
+ tree._size++;
181
+ return node;
182
+ }
183
+ }
184
+
185
+
186
+ /**
187
+ * Deletes i from the tree if it's there
188
+ * @param {Key} i
189
+ * @param {Tree} tree
190
+ * @param {Comparator} comparator
191
+ * @param {Tree} tree
192
+ * @return {Node} new root
193
+ */
194
+ function remove (i, t, comparator, tree) {
195
+ var x;
196
+ if (t === null) { return null; }
197
+ t = splay(i, t, comparator);
198
+ if (i === t.key) { /* found it */
199
+ if (t.left === null) {
200
+ x = t.right;
201
+ } else {
202
+ x = splay(i, t.left, comparator);
203
+ x.right = t.right;
204
+ }
205
+ tree._size--;
206
+ return x;
207
+ }
208
+ return t; /* It wasn't there */
209
+ }
210
+
211
+
212
+ function split (key, v, comparator) {
213
+ var left, right;
214
+ if (v === null) {
215
+ left = right = null;
216
+ } else {
217
+ v = splay(key, v, comparator);
218
+
219
+ var cmp = comparator(v.key, key);
220
+ if (cmp === 0) {
221
+ left = v.left;
222
+ right = v.right;
223
+ } else if (cmp < 0) {
224
+ right = v.right;
225
+ v.right = null;
226
+ left = v;
227
+ } else {
228
+ left = v.left;
229
+ v.left = null;
230
+ right = v;
231
+ }
232
+ }
233
+ return { left: left, right: right };
234
+ }
235
+
236
+
237
+ function merge (left, right, comparator) {
238
+ if (right === null) { return left; }
239
+ if (left === null) { return right; }
240
+
241
+ right = splay(left.key, right, comparator);
242
+ right.left = left;
243
+ return right;
244
+ }
245
+
246
+
247
+ /**
248
+ * Prints level of the tree
249
+ * @param {Node} root
250
+ * @param {String} prefix
251
+ * @param {Boolean} isTail
252
+ * @param {Array<string>} out
253
+ * @param {Function(node:Node):String} printNode
254
+ */
255
+ function printRow (root, prefix, isTail, out, printNode) {
256
+ if (root) {
257
+ out(("" + prefix + (isTail ? '└── ' : '├── ') + (printNode(root)) + "\n"));
258
+ var indent = prefix + (isTail ? ' ' : '│ ');
259
+ if (root.left) { printRow(root.left, indent, false, out, printNode); }
260
+ if (root.right) { printRow(root.right, indent, true, out, printNode); }
261
+ }
262
+ }
263
+
264
+
265
+ var Tree = function Tree (comparator) {
266
+ if ( comparator === void 0 ) comparator = DEFAULT_COMPARE;
267
+
268
+ this._comparator = comparator;
269
+ this._root = null;
270
+ this._size = 0;
271
+ };
272
+
273
+ var prototypeAccessors = { size: { configurable: true } };
274
+
275
+
276
+ /**
277
+ * Inserts a key, allows duplicates
278
+ * @param{Key} key
279
+ * @param{Value=} data
280
+ * @return {Node|null}
281
+ */
282
+ Tree.prototype.insert = function insert$1 (key, data) {
283
+ return this._root = insert(key, data, this._root, this._comparator, this);
284
+ };
285
+
286
+
287
+ /**
288
+ * Adds a key, if it is not present in the tree
289
+ * @param{Key} key
290
+ * @param{Value=} data
291
+ * @return {Node|null}
292
+ */
293
+ Tree.prototype.add = function add$1 (key, data) {
294
+ return this._root = add(key, data, this._root, this._comparator, this);
295
+ };
296
+
297
+
298
+ /**
299
+ * @param{Key} key
300
+ * @return {Node|null}
301
+ */
302
+ Tree.prototype.remove = function remove$1 (key) {
303
+ this._root = remove(key, this._root, this._comparator, this);
304
+ };
305
+
306
+
307
+ /**
308
+ * Removes and returns the node with smallest key
309
+ * @return {?Node}
310
+ */
311
+ Tree.prototype.pop = function pop () {
312
+ var node = this._root;
313
+ if (node) {
314
+ while (node.left) { node = node.left; }
315
+ this._root = splay(node.key,this._root, this._comparator);
316
+ this._root = remove(node.key, this._root, this._comparator, this);
317
+ return { key: node.key, data: node.data };
318
+ }
319
+ return null;
320
+ };
321
+
322
+
323
+ /**
324
+ * @param{Key} key
325
+ * @return {Node|null}
326
+ */
327
+ Tree.prototype.findStatic = function findStatic (key) {
328
+ var current = this._root;
329
+ var compare = this._comparator;
330
+ while (current) {
331
+ var cmp = compare(key, current.key);
332
+ if (cmp === 0) { return current; }
333
+ else if (cmp < 0) { current = current.left; }
334
+ else { current = current.right; }
335
+ }
336
+ return null;
337
+ };
338
+
339
+
340
+ /**
341
+ * @param{Key} key
342
+ * @return {Node|null}
343
+ */
344
+ Tree.prototype.find = function find (key) {
345
+ if (this._root) {
346
+ this._root = splay(key, this._root, this._comparator);
347
+ if (this._comparator(key, this._root.key) !== 0) { return null; }
348
+ }
349
+ return this._root;
350
+ };
351
+
352
+
353
+ /**
354
+ * @param{Key} key
355
+ * @return {Boolean}
356
+ */
357
+ Tree.prototype.contains = function contains (key) {
358
+ var current = this._root;
359
+ var compare = this._comparator;
360
+ while (current) {
361
+ var cmp = compare(key, current.key);
362
+ if (cmp === 0) { return true; }
363
+ else if (cmp < 0) { current = current.left; }
364
+ else { current = current.right; }
365
+ }
366
+ return false;
367
+ };
368
+
369
+
370
+ /**
371
+ * @param{Visitor} visitor
372
+ * @param{*=} ctx
373
+ * @return {SplayTree}
374
+ */
375
+ Tree.prototype.forEach = function forEach (visitor, ctx) {
376
+ var current = this._root;
377
+ var Q = [];/* Initialize stack s */
378
+ var done = false;
379
+
380
+ while (!done) {
381
+ if (current !==null) {
382
+ Q.push(current);
383
+ current = current.left;
384
+ } else {
385
+ if (Q.length !== 0) {
386
+ current = Q.pop();
387
+ visitor.call(ctx, current);
388
+
389
+ current = current.right;
390
+ } else { done = true; }
391
+ }
392
+ }
393
+ return this;
394
+ };
395
+
396
+
397
+ /**
398
+ * Walk key range from `low` to `high`. Stops if `fn` returns a value.
399
+ * @param{Key} low
400
+ * @param{Key} high
401
+ * @param{Function} fn
402
+ * @param{*?} ctx
403
+ * @return {SplayTree}
404
+ */
405
+ Tree.prototype.range = function range (low, high, fn, ctx) {
406
+ var this$1 = this;
407
+
408
+ var Q = [];
409
+ var compare = this._comparator;
410
+ var node = this._root, cmp;
411
+
412
+ while (Q.length !== 0 || node) {
413
+ if (node) {
414
+ Q.push(node);
415
+ node = node.left;
416
+ } else {
417
+ node = Q.pop();
418
+ cmp = compare(node.key, high);
419
+ if (cmp > 0) {
420
+ break;
421
+ } else if (compare(node.key, low) >= 0) {
422
+ if (fn.call(ctx, node)) { return this$1; } // stop if smth is returned
423
+ }
424
+ node = node.right;
425
+ }
426
+ }
427
+ return this;
428
+ };
429
+
430
+
431
+ /**
432
+ * Returns array of keys
433
+ * @return {Array<Key>}
434
+ */
435
+ Tree.prototype.keys = function keys () {
436
+ var keys = [];
437
+ this.forEach(function (ref) {
438
+ var key = ref.key;
439
+
440
+ return keys.push(key);
441
+ });
442
+ return keys;
443
+ };
444
+
445
+
446
+ /**
447
+ * Returns array of all the data in the nodes
448
+ * @return {Array<Value>}
449
+ */
450
+ Tree.prototype.values = function values () {
451
+ var values = [];
452
+ this.forEach(function (ref) {
453
+ var data = ref.data;
454
+
455
+ return values.push(data);
456
+ });
457
+ return values;
458
+ };
459
+
460
+
461
+ /**
462
+ * @return {Key|null}
463
+ */
464
+ Tree.prototype.min = function min () {
465
+ if (this._root) { return this.minNode(this._root).key; }
466
+ return null;
467
+ };
468
+
469
+
470
+ /**
471
+ * @return {Key|null}
472
+ */
473
+ Tree.prototype.max = function max () {
474
+ if (this._root) { return this.maxNode(this._root).key; }
475
+ return null;
476
+ };
477
+
478
+
479
+ /**
480
+ * @return {Node|null}
481
+ */
482
+ Tree.prototype.minNode = function minNode (t) {
483
+ if ( t === void 0 ) t = this._root;
484
+
485
+ if (t) { while (t.left) { t = t.left; } }
486
+ return t;
487
+ };
488
+
489
+
490
+ /**
491
+ * @return {Node|null}
492
+ */
493
+ Tree.prototype.maxNode = function maxNode (t) {
494
+ if ( t === void 0 ) t = this._root;
495
+
496
+ if (t) { while (t.right) { t = t.right; } }
497
+ return t;
498
+ };
499
+
500
+
501
+ /**
502
+ * Returns node at given index
503
+ * @param{number} index
504
+ * @return {?Node}
505
+ */
506
+ Tree.prototype.at = function at (index) {
507
+ var current = this._root, done = false, i = 0;
508
+ var Q = [];
509
+
510
+ while (!done) {
511
+ if (current) {
512
+ Q.push(current);
513
+ current = current.left;
514
+ } else {
515
+ if (Q.length > 0) {
516
+ current = Q.pop();
517
+ if (i === index) { return current; }
518
+ i++;
519
+ current = current.right;
520
+ } else { done = true; }
521
+ }
522
+ }
523
+ return null;
524
+ };
525
+
526
+
527
+ /**
528
+ * @param{Node} d
529
+ * @return {Node|null}
530
+ */
531
+ Tree.prototype.next = function next (d) {
532
+ var root = this._root;
533
+ var successor = null;
534
+
535
+ if (d.right) {
536
+ successor = d.right;
537
+ while (successor.left) { successor = successor.left; }
538
+ return successor;
539
+ }
540
+
541
+ var comparator = this._comparator;
542
+ while (root) {
543
+ var cmp = comparator(d.key, root.key);
544
+ if (cmp === 0) { break; }
545
+ else if (cmp < 0) {
546
+ successor = root;
547
+ root = root.left;
548
+ } else { root = root.right; }
549
+ }
550
+
551
+ return successor;
552
+ };
553
+
554
+
555
+ /**
556
+ * @param{Node} d
557
+ * @return {Node|null}
558
+ */
559
+ Tree.prototype.prev = function prev (d) {
560
+ var root = this._root;
561
+ var predecessor = null;
562
+
563
+ if (d.left !== null) {
564
+ predecessor = d.left;
565
+ while (predecessor.right) { predecessor = predecessor.right; }
566
+ return predecessor;
567
+ }
568
+
569
+ var comparator = this._comparator;
570
+ while (root) {
571
+ var cmp = comparator(d.key, root.key);
572
+ if (cmp === 0) { break; }
573
+ else if (cmp < 0) { root = root.left; }
574
+ else {
575
+ predecessor = root;
576
+ root = root.right;
577
+ }
578
+ }
579
+ return predecessor;
580
+ };
581
+
582
+
583
+ /**
584
+ * @return {SplayTree}
585
+ */
586
+ Tree.prototype.clear = function clear () {
587
+ this._root = null;
588
+ this._size = 0;
589
+ return this;
590
+ };
591
+
592
+
593
+ /**
594
+ * @return {NodeList}
595
+ */
596
+ Tree.prototype.toList = function toList$1 () {
597
+ return toList(this._root);
598
+ };
599
+
600
+
601
+ /**
602
+ * Bulk-load items. Both array have to be same size
603
+ * @param{Array<Key>} keys
604
+ * @param{Array<Value>}[values]
605
+ * @param{Boolean} [presort=false] Pre-sort keys and values, using
606
+ * tree's comparator. Sorting is done
607
+ * in-place
608
+ * @return {AVLTree}
609
+ */
610
+ Tree.prototype.load = function load (keys, values, presort) {
611
+ if ( keys === void 0 ) keys = [];
612
+ if ( values === void 0 ) values = [];
613
+ if ( presort === void 0 ) presort = false;
614
+
615
+ var size = keys.length;
616
+ var comparator = this._comparator;
617
+
618
+ // sort if needed
619
+ if (presort) { sort(keys, values, 0, size - 1, comparator); }
620
+
621
+ if (this._root === null) { // empty tree
622
+ this._root = loadRecursive(this._root, keys, values, 0, size);
623
+ this._size = size;
624
+ } else { // that re-builds the whole tree from two in-order traversals
625
+ var mergedList = mergeLists(this.toList(), createList(keys, values), comparator);
626
+ size = this._size + size;
627
+ this._root = sortedListToBST({ head: mergedList }, 0, size);
628
+ }
629
+ return this;
630
+ };
631
+
632
+
633
+ /**
634
+ * @return {Boolean}
635
+ */
636
+ Tree.prototype.isEmpty = function isEmpty () { return this._root === null; };
637
+
638
+ prototypeAccessors.size.get = function () { return this._size; };
639
+
640
+
641
+ /**
642
+ * @param{NodePrinter=} printNode
643
+ * @return {String}
644
+ */
645
+ Tree.prototype.toString = function toString (printNode) {
646
+ if ( printNode === void 0 ) printNode = function (n) { return n.key; };
647
+
648
+ var out = [];
649
+ printRow(this._root, '', true, function (v) { return out.push(v); }, printNode);
650
+ return out.join('');
651
+ };
652
+
653
+
654
+ Tree.prototype.update = function update (key, newKey, newData) {
655
+ var comparator = this._comparator;
656
+ var ref = split(key, this._root, comparator);
657
+ var left = ref.left;
658
+ var right = ref.right;
659
+ this._size--;
660
+ if (comparator(key, newKey) < 0) {
661
+ right = insert(newKey, newData, right, comparator, this);
662
+ } else {
663
+ left = insert(newKey, newData, left, comparator, this);
664
+ }
665
+ this._root = merge(left, right, comparator);
666
+ };
667
+
668
+
669
+ Tree.prototype.split = function split$1 (key) {
670
+ return split(key, this._root, this._comparator);
671
+ };
672
+
673
+ Object.defineProperties( Tree.prototype, prototypeAccessors );
674
+
675
+
676
+ function loadRecursive (parent, keys, values, start, end) {
677
+ var size = end - start;
678
+ if (size > 0) {
679
+ var middle = start + Math.floor(size / 2);
680
+ var key = keys[middle];
681
+ var data = values[middle];
682
+ var node = { key: key, data: data, parent: parent };
683
+ node.left = loadRecursive(node, keys, values, start, middle);
684
+ node.right = loadRecursive(node, keys, values, middle + 1, end);
685
+ return node;
686
+ }
687
+ return null;
688
+ }
689
+
690
+
691
+ function createList(keys, values) {
692
+ var head = { next: null };
693
+ var p = head;
694
+ for (var i = 0; i < keys.length; i++) {
695
+ p = p.next = { key: keys[i], data: values[i] };
696
+ }
697
+ p.next = null;
698
+ return head.next;
699
+ }
700
+
701
+
702
+ function toList (root) {
703
+ var current = root;
704
+ var Q = [], done = false;
705
+
706
+ var head = { next: null };
707
+ var p = head;
708
+
709
+ while (!done) {
710
+ if (current) {
711
+ Q.push(current);
712
+ current = current.left;
713
+ } else {
714
+ if (Q.length > 0) {
715
+ current = p = p.next = Q.pop();
716
+ current = current.right;
717
+ } else { done = true; }
718
+ }
719
+ }
720
+ p.next = null; // that'll work even if the tree was empty
721
+ return head.next;
722
+ }
723
+
724
+
725
+ function sortedListToBST(list, start, end) {
726
+ var size = end - start;
727
+ if (size > 0) {
728
+ var middle = start + Math.floor(size / 2);
729
+ var left = sortedListToBST(list, start, middle);
730
+
731
+ var root = list.head;
732
+ root.left = left;
733
+
734
+ list.head = list.head.next;
735
+
736
+ root.right = sortedListToBST(list, middle + 1, end);
737
+ return root;
738
+ }
739
+ return null;
740
+ }
741
+
742
+
743
+ function mergeLists (l1, l2, compare) {
744
+ if ( compare === void 0 ) compare = function (a, b) { return a - b; };
745
+
746
+ var head = {}; // dummy
747
+ var p = head;
748
+
749
+ var p1 = l1;
750
+ var p2 = l2;
751
+
752
+ while (p1 !== null && p2 !== null) {
753
+ if (compare(p1.key, p2.key) < 0) {
754
+ p.next = p1;
755
+ p1 = p1.next;
756
+ } else {
757
+ p.next = p2;
758
+ p2 = p2.next;
759
+ }
760
+ p = p.next;
761
+ }
762
+
763
+ if (p1 !== null) { p.next = p1; }
764
+ else if (p2 !== null) { p.next = p2; }
765
+
766
+ return head.next;
767
+ }
768
+
769
+
770
+ function sort(keys, values, left, right, compare) {
771
+ if (left >= right) { return; }
772
+
773
+ var pivot = keys[(left + right) >> 1];
774
+ var i = left - 1;
775
+ var j = right + 1;
776
+
777
+ while (true) {
778
+ do { i++; } while (compare(keys[i], pivot) < 0);
779
+ do { j--; } while (compare(keys[j], pivot) > 0);
780
+ if (i >= j) { break; }
781
+
782
+ var tmp = keys[i];
783
+ keys[i] = keys[j];
784
+ keys[j] = tmp;
785
+
786
+ tmp = values[i];
787
+ values[i] = values[j];
788
+ values[j] = tmp;
789
+ }
790
+
791
+ sort(keys, values, left, j, compare);
792
+ sort(keys, values, j + 1, right, compare);
793
+ }
794
+
795
+ return Tree;
796
+
797
+ })));