@live-change/flatten-interval-tree 0.8.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +8 -0
- package/.travis.yml +14 -0
- package/LICENSE +21 -0
- package/README.md +172 -0
- package/dist/main.cjs.js +799 -0
- package/dist/main.esm.js +794 -0
- package/dist/main.umd.js +805 -0
- package/docs/Interval.html +1609 -0
- package/docs/IntervalTree.html +1506 -0
- package/docs/classes_interval.js.html +173 -0
- package/docs/fonts/OpenSans-Bold-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Bold-webfont.svg +1830 -0
- package/docs/fonts/OpenSans-Bold-webfont.woff +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.svg +1830 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.svg +1830 -0
- package/docs/fonts/OpenSans-Italic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Light-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Light-webfont.svg +1831 -0
- package/docs/fonts/OpenSans-Light-webfont.woff +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.svg +1835 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.svg +1831 -0
- package/docs/fonts/OpenSans-Regular-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Semibold-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Semibold-webfont.svg +1830 -0
- package/docs/fonts/OpenSans-Semibold-webfont.ttf +0 -0
- package/docs/fonts/OpenSans-Semibold-webfont.woff +0 -0
- package/docs/fonts/OpenSans-SemiboldItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-SemiboldItalic-webfont.svg +1830 -0
- package/docs/fonts/OpenSans-SemiboldItalic-webfont.ttf +0 -0
- package/docs/fonts/OpenSans-SemiboldItalic-webfont.woff +0 -0
- package/docs/index.html +197 -0
- package/docs/index.js.html +624 -0
- package/docs/interval.js.html +184 -0
- package/docs/intervalTree.js.html +624 -0
- package/docs/scripts/linenumber.js +25 -0
- package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
- package/docs/scripts/prettify/lang-css.js +2 -0
- package/docs/scripts/prettify/prettify.js +28 -0
- package/docs/styles/jsdoc-default.css +692 -0
- package/docs/styles/prettify-jsdoc.css +111 -0
- package/docs/styles/prettify-tomorrow.css +132 -0
- package/examples/browser/index.html +49 -0
- package/examples/create-react-app/package.json +15 -0
- package/examples/create-react-app/public/index.html +11 -0
- package/examples/create-react-app/src/App.js +38 -0
- package/examples/create-react-app/src/ComposersList.js +15 -0
- package/examples/create-react-app/src/index.js +5 -0
- package/examples/es6-module/index.html +50 -0
- package/examples/nodejs/index.js +23 -0
- package/index.d.ts +65 -0
- package/index.js +6 -0
- package/package.json +52 -0
- package/rollup.config.js +21 -0
- package/src/classes/interval.js +131 -0
- package/src/classes/intervalTree.js +564 -0
- package/src/classes/node.js +97 -0
- package/src/utils/constants.js +16 -0
- package/test/intervalTree.js +232 -0
- package/test/node.js +64 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<title>interval.js - Documentation</title>
|
|
7
|
+
|
|
8
|
+
<script src="scripts/prettify/prettify.js"></script>
|
|
9
|
+
<script src="scripts/prettify/lang-css.js"></script>
|
|
10
|
+
<!--[if lt IE 9]>
|
|
11
|
+
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
12
|
+
<![endif]-->
|
|
13
|
+
<link type="text/css" rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
|
|
14
|
+
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
|
15
|
+
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
|
16
|
+
</head>
|
|
17
|
+
<body>
|
|
18
|
+
|
|
19
|
+
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
|
20
|
+
<label for="nav-trigger" class="navicon-button x">
|
|
21
|
+
<div class="navicon"></div>
|
|
22
|
+
</label>
|
|
23
|
+
|
|
24
|
+
<label for="nav-trigger" class="overlay"></label>
|
|
25
|
+
|
|
26
|
+
<nav>
|
|
27
|
+
<li class="nav-link nav-home-link"><a href="index.html">Home</a></li><li class="nav-heading">Classes</li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="Interval.html">Interval</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Interval.html#.comparable_less_than">comparable_less_than</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Interval.html#.comparable_max">comparable_max</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Interval.html#clone">clone</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Interval.html#equal_to">equal_to</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Interval.html#intersect">intersect</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Interval.html#less_than">less_than</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Interval.html#merge">merge</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Interval.html#not_intersect">not_intersect</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Interval.html#output">output</a></span></li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="IntervalTree.html">IntervalTree</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="IntervalTree.html#exist">exist</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="IntervalTree.html#forEach">forEach</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="IntervalTree.html#insert">insert</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="IntervalTree.html#isEmpty">isEmpty</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="IntervalTree.html#map">map</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="IntervalTree.html#remove">remove</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="IntervalTree.html#search">search</a></span></li>
|
|
28
|
+
</nav>
|
|
29
|
+
|
|
30
|
+
<div id="main">
|
|
31
|
+
|
|
32
|
+
<h1 class="page-title">interval.js</h1>
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
<section>
|
|
41
|
+
<article>
|
|
42
|
+
<pre class="prettyprint source linenums"><code>/**
|
|
43
|
+
* Created by Alex Bol on 4/1/2017.
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Interval is a pair of numbers or a pair of any comparable objects on which may be defined predicates
|
|
48
|
+
* *equal*, *less* and method *max(p1, p1)* that returns maximum in a pair.
|
|
49
|
+
* When interval is an object rather than pair of numbers, this object should have properties *low*, *high*, *max*
|
|
50
|
+
* and implement methods *less_than(), equal_to(), intersect(), not_intersect(), clone(), output()*.
|
|
51
|
+
* Two static methods *comparable_max(), comparable_less_than()* define how to compare values in pair. <br/>
|
|
52
|
+
* This interface is described in typescript definition file *index.d.ts*
|
|
53
|
+
*
|
|
54
|
+
* Axis aligned rectangle is an example of such interval.
|
|
55
|
+
* We may look at rectangle as an interval between its low left and top right corners.
|
|
56
|
+
* See **Box** class in [flatten-js](https://github.com/alexbol99/flatten-js) library as the example
|
|
57
|
+
* of Interval interface implementation
|
|
58
|
+
* @type {Interval}
|
|
59
|
+
*/
|
|
60
|
+
const Interval = class Interval {
|
|
61
|
+
/**
|
|
62
|
+
* Accept two comparable values and creates new instance of interval
|
|
63
|
+
* Predicate Interval.comparable_less(low, high) supposed to return true on these values
|
|
64
|
+
* @param low
|
|
65
|
+
* @param high
|
|
66
|
+
*/
|
|
67
|
+
constructor(low, high) {
|
|
68
|
+
this.low = low;
|
|
69
|
+
this.high = high;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Clone interval
|
|
74
|
+
* @returns {Interval}
|
|
75
|
+
*/
|
|
76
|
+
clone() {
|
|
77
|
+
return new Interval(this.low, this.high);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Propery max returns clone of this interval
|
|
82
|
+
* @returns {Interval}
|
|
83
|
+
*/
|
|
84
|
+
get max() {
|
|
85
|
+
return this.clone(); // this.high;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Predicate returns true is this interval less than other interval
|
|
90
|
+
* @param other_interval
|
|
91
|
+
* @returns {boolean}
|
|
92
|
+
*/
|
|
93
|
+
less_than(other_interval) {
|
|
94
|
+
return this.low < other_interval.low ||
|
|
95
|
+
this.low == other_interval.low && this.high < other_interval.high;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Predicate returns true is this interval equals to other interval
|
|
100
|
+
* @param other_interval
|
|
101
|
+
* @returns {boolean}
|
|
102
|
+
*/
|
|
103
|
+
equal_to(other_interval) {
|
|
104
|
+
return this.low == other_interval.low && this.high == other_interval.high;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Predicate returns true if this interval intersects other interval
|
|
109
|
+
* @param other_interval
|
|
110
|
+
* @returns {boolean}
|
|
111
|
+
*/
|
|
112
|
+
intersect(other_interval) {
|
|
113
|
+
return !this.not_intersect(other_interval);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Predicate returns true if this interval does not intersect other interval
|
|
118
|
+
* @param other_interval
|
|
119
|
+
* @returns {boolean}
|
|
120
|
+
*/
|
|
121
|
+
not_intersect(other_interval) {
|
|
122
|
+
return (this.high < other_interval.low || other_interval.high < this.low);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Returns new interval merged with other interval
|
|
127
|
+
* @param {Interval} interval - Other interval to merge with
|
|
128
|
+
* @returns {Interval}
|
|
129
|
+
*/
|
|
130
|
+
merge(other_interval) {
|
|
131
|
+
return new Interval(
|
|
132
|
+
this.low === undefined ? other_interval.low : Math.min(this.low, other_interval.low),
|
|
133
|
+
this.high === undefined ? other_interval.high : Math.max(this.high, other_interval.high)
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Returns how key should return
|
|
139
|
+
*/
|
|
140
|
+
output() {
|
|
141
|
+
return [this.low, this.high];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Function returns maximum between two comparable values
|
|
146
|
+
* @param interval1
|
|
147
|
+
* @param interval2
|
|
148
|
+
* @returns {Interval}
|
|
149
|
+
*/
|
|
150
|
+
static comparable_max(interval1, interval2) {
|
|
151
|
+
return interval1.merge(interval2);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Predicate returns true if first value less than second value
|
|
156
|
+
* @param val1
|
|
157
|
+
* @param val2
|
|
158
|
+
* @returns {boolean}
|
|
159
|
+
*/
|
|
160
|
+
static comparable_less_than(val1, val2 ) {
|
|
161
|
+
return val1 < val2;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export default Interval;
|
|
166
|
+
</code></pre>
|
|
167
|
+
</article>
|
|
168
|
+
</section>
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
</div>
|
|
174
|
+
|
|
175
|
+
<br class="clear">
|
|
176
|
+
|
|
177
|
+
<footer>
|
|
178
|
+
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.2</a> on Thu Jul 04 2019 20:41:00 GMT+0300 (Israel Daylight Time) using the Minami theme.
|
|
179
|
+
</footer>
|
|
180
|
+
|
|
181
|
+
<script>prettyPrint();</script>
|
|
182
|
+
<script src="scripts/linenumber.js"></script>
|
|
183
|
+
</body>
|
|
184
|
+
</html>
|