jsxgraph 1.14.0 → 1.14.1
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/CHANGELOG.md +33 -3
- package/distrib/docs/3d_linspace3d.js.html +16 -10
- package/distrib/docs/3d_point3d.js.html +0 -5
- package/distrib/docs/3d_sphere3d.js.html +92 -69
- package/distrib/docs/3d_view3d.js.html +24 -16
- package/distrib/docs/Angle.html +7 -7
- package/distrib/docs/CircumcircleSector.html +2 -2
- package/distrib/docs/Conic.html +1 -1
- package/distrib/docs/Ellipse.html +23 -1
- package/distrib/docs/Hyperbola.html +24 -1
- package/distrib/docs/JXG.Board.infobox.html +1 -1
- package/distrib/docs/JXG.Board_.html +130 -130
- package/distrib/docs/JXG.CanvasRenderer.html +10 -10
- package/distrib/docs/JXG.Composition.html +3 -3
- package/distrib/docs/JXG.GeometryElement.html +26 -26
- package/distrib/docs/JXG.Math.Numerics.html +45 -47
- package/distrib/docs/JXG.Math.Statistics.html +14 -15
- package/distrib/docs/JXG.Math.Tiling.html +3 -7
- package/distrib/docs/JXG.Math.html +101 -83
- package/distrib/docs/JXG.Point3D.html +2 -2
- package/distrib/docs/JXG.SVGRenderer.html +12 -12
- package/distrib/docs/JXG.Sphere3D.html +1255 -2
- package/distrib/docs/JXG.View3D.html +29 -29
- package/distrib/docs/JXG.html +20 -20
- package/distrib/docs/MajorSector.html +1 -1
- package/distrib/docs/MinorSector.html +1 -1
- package/distrib/docs/NonReflexAngle.html +1 -1
- package/distrib/docs/Parabola.html +1 -1
- package/distrib/docs/Point3D.html +1 -1
- package/distrib/docs/ReflexAngle.html +1 -1
- package/distrib/docs/Sector.html +12 -12
- package/distrib/docs/Sphere3D.html +17 -1
- package/distrib/docs/View3D.html +1 -1
- package/distrib/docs/base_board.js.html +63 -13
- package/distrib/docs/base_composition.js.html +3 -3
- package/distrib/docs/base_constants.js.html +1 -1
- package/distrib/docs/base_element.js.html +2 -1
- package/distrib/docs/base_text.js.html +2 -2
- package/distrib/docs/element_conic.js.html +35 -1
- package/distrib/docs/element_sector.js.html +6 -3
- package/distrib/docs/index.html +1 -1
- package/distrib/docs/math_math.js.html +64 -35
- package/distrib/docs/math_numerics.js.html +13 -12
- package/distrib/docs/math_statistics.js.html +19 -19
- package/distrib/docs/math_tiling.js.html +6 -288
- package/distrib/docs/parser_jessiecode.js.html +1 -1
- package/distrib/docs/renderer_canvas.js.html +7 -6
- package/distrib/docs/renderer_svg.js.html +15 -7
- package/distrib/docs/scripts/jsxgraphcore.js +2 -2
- package/distrib/docs/styles/jsxgraph.css +1 -1
- package/distrib/docs/utils_type.js.html +11 -4
- package/distrib/geogebra.min.js +1 -1
- package/distrib/geonext.min.js +1 -1
- package/distrib/index.d.ts +11 -0
- package/distrib/intergeo.min.js +1 -1
- package/distrib/jsxgraph.css +1 -1
- package/distrib/jsxgraphcore.js +2 -2
- package/distrib/jsxgraphcore.mjs +2 -2
- package/distrib/jsxgraphcore.mjs.map +1 -1
- package/distrib/jsxgraphsrc.js +380 -496
- package/distrib/jsxgraphsrc.mjs +380 -496
- package/distrib/jsxgraphsrc.mjs.map +1 -1
- package/package.json +10 -12
- package/src/3d/linspace3d.js +16 -10
- package/src/3d/point3d.js +0 -5
- package/src/3d/sphere3d.js +92 -69
- package/src/3d/view3d.js +24 -16
- package/src/base/board.js +63 -13
- package/src/base/composition.js +3 -3
- package/src/base/constants.js +1 -1
- package/src/base/element.js +2 -1
- package/src/base/text.js +2 -2
- package/src/element/conic.js +35 -1
- package/src/element/sector.js +6 -3
- package/src/index.d.ts +11 -0
- package/src/math/math.js +64 -35
- package/src/math/numerics.js +13 -12
- package/src/math/statistics.js +19 -19
- package/src/math/tiling.js +6 -288
- package/src/parser/jessiecode.js +1 -1
- package/src/renderer/canvas.js +7 -6
- package/src/renderer/svg.js +15 -7
- package/src/utils/type.js +11 -4
- package/src/unused/bst.js +0 -475
- package/src/unused/heap.js +0 -135
- package/src/unused/locus.js +0 -162
- package/src/unused/server/JXG.py +0 -74
- package/src/unused/server/JXGServer.py +0 -94
- package/src/unused/server/JXGServerModule.py +0 -9
- package/src/unused/server/README.md +0 -63
- package/src/unused/server/RStats.py +0 -45
- package/src/unused/server/YahooFinance.py +0 -81
- package/src/unused/server/fft.py +0 -136
- package/src/unused/server/geoloci.py +0 -210
- package/src/unused/server/jxggroebner.py +0 -219
- package/src/unused/server/jxgtestplugin.py +0 -19
- package/src/unused/server/server.js +0 -280
- package/src/unused/sketch.js +0 -2895
- package/src/unused/symbolic.js +0 -416
package/src/unused/bst.js
DELETED
|
@@ -1,475 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2008-2026
|
|
3
|
-
Matthias Ehmann,
|
|
4
|
-
Michael Gerhaeuser,
|
|
5
|
-
Carsten Miller,
|
|
6
|
-
Bianca Valentin,
|
|
7
|
-
Alfred Wassermann,
|
|
8
|
-
Peter Wilfahrt
|
|
9
|
-
|
|
10
|
-
This file is part of JSXGraph.
|
|
11
|
-
|
|
12
|
-
JSXGraph is free software dual licensed under the GNU LGPL or MIT License.
|
|
13
|
-
|
|
14
|
-
You can redistribute it and/or modify it under the terms of the
|
|
15
|
-
|
|
16
|
-
* GNU Lesser General Public License as published by
|
|
17
|
-
the Free Software Foundation, either version 3 of the License, or
|
|
18
|
-
(at your option) any later version
|
|
19
|
-
OR
|
|
20
|
-
* MIT License: https://github.com/jsxgraph/jsxgraph/blob/master/LICENSE.MIT
|
|
21
|
-
|
|
22
|
-
JSXGraph is distributed in the hope that it will be useful,
|
|
23
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
24
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
25
|
-
GNU Lesser General Public License for more details.
|
|
26
|
-
|
|
27
|
-
You should have received a copy of the GNU Lesser General Public License and
|
|
28
|
-
the MIT License along with JSXGraph. If not, see <https://www.gnu.org/licenses/>
|
|
29
|
-
and <https://opensource.org/licenses/MIT/>.
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/*global JXG:true, define: true*/
|
|
33
|
-
/*jslint nomen: true, plusplus: true*/
|
|
34
|
-
|
|
35
|
-
import Mat from "./math.js";
|
|
36
|
-
import Type from "../utils/type.js";
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Balanced binary search tree
|
|
40
|
-
*/
|
|
41
|
-
Mat.BST = function () {
|
|
42
|
-
this.head = null;
|
|
43
|
-
this.z = null;
|
|
44
|
-
this.randomized = true;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* public
|
|
49
|
-
*/
|
|
50
|
-
Mat.BST.prototype.newNode = function (it, le, ri, n) {
|
|
51
|
-
return {
|
|
52
|
-
item: it,
|
|
53
|
-
l: le,
|
|
54
|
-
r: ri,
|
|
55
|
-
N: n
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
Mat.BST.prototype.init = function (random) {
|
|
60
|
-
this.z = this.newNode(null, 0, 0, 0);
|
|
61
|
-
this.head = this.z;
|
|
62
|
-
|
|
63
|
-
if (Type.exists(random)) {
|
|
64
|
-
this.randomized = random;
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
Mat.BST.prototype.count = function () {
|
|
69
|
-
return this.head.N;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
Mat.BST.prototype.search = function (val) {
|
|
73
|
-
return this.searchR(this.head, val);
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
Mat.BST.prototype.insert = function (item) {
|
|
77
|
-
if (this.randomized) {
|
|
78
|
-
this.head = this.insertRandR(this.head, item);
|
|
79
|
-
} else {
|
|
80
|
-
this.head = this.insertR(this.head, item);
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
Mat.BST.prototype.traverse = function (h, visit) {
|
|
85
|
-
if (this.isNil(h)) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
visit(h);
|
|
89
|
-
this.traverse(h.l, visit);
|
|
90
|
-
this.traverse(h.r, visit);
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
Mat.BST.prototype.insertHead = function (item) {
|
|
94
|
-
this.head = this.insertT(this.head, item);
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
Mat.BST.prototype.deleteNode = function (v) {
|
|
98
|
-
this.head = this.deleteR(this.head, v);
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
Mat.BST.prototype.join = function (a, b) {
|
|
102
|
-
if (this.isNil(b)) {
|
|
103
|
-
return a;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (this.isNil(a)) {
|
|
107
|
-
return b;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
b = this.insertT(b, a.item);
|
|
111
|
-
b.l = this.join(a.l, b.l);
|
|
112
|
-
b.r = this.join(a.r, b.r);
|
|
113
|
-
|
|
114
|
-
this.fixN(b);
|
|
115
|
-
|
|
116
|
-
return b;
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
Mat.BST.prototype.select = function (k) {
|
|
120
|
-
return this.selectR(this.head, k);
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
Mat.BST.prototype.balance = function () {
|
|
124
|
-
this.head = this.balanceR(this.head);
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
Mat.BST.prototype.show = function () {
|
|
128
|
-
this.showR(this.head, 0);
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
Mat.BST.prototype.joinRand = function (a, b) {
|
|
132
|
-
if (Math.random() / (1 / (a.N + b.N) + 1) < a.N) {
|
|
133
|
-
return this.joinRandR(a, b);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return this.joinRandR(b, a);
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
Mat.BST.prototype.minimum = function (h) {
|
|
140
|
-
if (this.isNil(h)) {
|
|
141
|
-
return h;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
while (!this.isNil(h.l)) {
|
|
145
|
-
h = h.l;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return h;
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
Mat.BST.prototype.maximum = function (h) {
|
|
152
|
-
if (this.isNil(h)) {
|
|
153
|
-
return h;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
while (!this.isNil(h.r)) {
|
|
157
|
-
h = h.r;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return h;
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
Mat.BST.prototype.next = function (node) {
|
|
164
|
-
var nxt,
|
|
165
|
-
h = this.head;
|
|
166
|
-
|
|
167
|
-
// Trivial case
|
|
168
|
-
if (this.isNil(h)) {
|
|
169
|
-
return h;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
if (!this.isNil(node.r)) {
|
|
173
|
-
return this.minimum(node.r);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
while (!this.isNil(h)) {
|
|
177
|
-
if (node.item < h.item) {
|
|
178
|
-
nxt = h;
|
|
179
|
-
h = h.l;
|
|
180
|
-
} else if (h.item < node.item) {
|
|
181
|
-
h = h.r;
|
|
182
|
-
} else {
|
|
183
|
-
break;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
return nxt;
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
Mat.BST.prototype.prev = function (node) {
|
|
191
|
-
var nxt,
|
|
192
|
-
h = this.head;
|
|
193
|
-
|
|
194
|
-
// Trivial case
|
|
195
|
-
if (this.isNil(h)) {
|
|
196
|
-
return h;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
if (!this.isNil(node.l)) {
|
|
200
|
-
return this.maximum(node.l);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
while (!this.isNil(h)) {
|
|
204
|
-
if (node.item < h.item) {
|
|
205
|
-
h = h.l;
|
|
206
|
-
} else if (h.item < node.item) {
|
|
207
|
-
nxt = h;
|
|
208
|
-
h = h.r;
|
|
209
|
-
} else {
|
|
210
|
-
break;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
return nxt;
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* private
|
|
219
|
-
*/
|
|
220
|
-
Mat.BST.prototype.fixN = function (h) {
|
|
221
|
-
h.N = h.l.N + h.r.N + 1;
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
Mat.BST.prototype.isNil = function (h) {
|
|
225
|
-
return h.l === 0 && h.r === 0;
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
Mat.BST.prototype.searchR = function (h, val) {
|
|
229
|
-
var t = h.item;
|
|
230
|
-
if (this.isNil(h)) {
|
|
231
|
-
return this.z;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
if (val === t) {
|
|
235
|
-
return h;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
if (val < t) {
|
|
239
|
-
return this.searchR(h.l, val);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
return this.searchR(h.r, val);
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
Mat.BST.prototype.insertR = function (h, item) {
|
|
246
|
-
if (this.isNil(h)) {
|
|
247
|
-
return this.newNode(item, this.z, this.z, 1);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
if (item < h.item) {
|
|
251
|
-
h.l = this.insertR(h.l, item);
|
|
252
|
-
} else {
|
|
253
|
-
h.r = this.insertR(h.r, item);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
h.N++;
|
|
257
|
-
return h;
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
Mat.BST.prototype.rotR = function (h) {
|
|
261
|
-
var x = h.l;
|
|
262
|
-
|
|
263
|
-
h.l = x.r;
|
|
264
|
-
x.r = h;
|
|
265
|
-
|
|
266
|
-
this.fixN(h);
|
|
267
|
-
this.fixN(x);
|
|
268
|
-
|
|
269
|
-
return x;
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
Mat.BST.prototype.rotL = function (h) {
|
|
273
|
-
var x = h.r,
|
|
274
|
-
n = x.N;
|
|
275
|
-
|
|
276
|
-
h.r = x.l;
|
|
277
|
-
x.l = h;
|
|
278
|
-
|
|
279
|
-
this.fixN(h);
|
|
280
|
-
this.fixN(x);
|
|
281
|
-
|
|
282
|
-
return x;
|
|
283
|
-
};
|
|
284
|
-
|
|
285
|
-
Mat.BST.prototype.insertT = function (h, item) {
|
|
286
|
-
if (this.isNil(h)) {
|
|
287
|
-
return this.newNode(item, this.z, this.z, 1);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
if (item < h.item) {
|
|
291
|
-
h.l = this.insertT(h.l, item);
|
|
292
|
-
h = this.rotR(h);
|
|
293
|
-
} else {
|
|
294
|
-
h.r = this.insertT(h.r, item);
|
|
295
|
-
h = this.rotL(h);
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
return h;
|
|
299
|
-
};
|
|
300
|
-
|
|
301
|
-
Mat.BST.prototype.selectR = function (h, k) {
|
|
302
|
-
var t;
|
|
303
|
-
|
|
304
|
-
if (this.isNil(h)) {
|
|
305
|
-
return null;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
t = this.isNil(h.l) ? 0 : h.l.N;
|
|
309
|
-
|
|
310
|
-
if (t > k) {
|
|
311
|
-
return this.selectR(h.l, k);
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
if (t < k) {
|
|
315
|
-
return this.selectR(h.r, k - t - 1);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
return h.item;
|
|
319
|
-
};
|
|
320
|
-
|
|
321
|
-
Mat.BST.prototype.partR = function (h, k) {
|
|
322
|
-
var t = h.l.N;
|
|
323
|
-
|
|
324
|
-
if (t > k) {
|
|
325
|
-
h.l = this.partR(h.l, k);
|
|
326
|
-
h = this.rotR(h);
|
|
327
|
-
this.head = h;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
if (t < k) {
|
|
331
|
-
h.r = this.partR(h.r, k - t - 1);
|
|
332
|
-
h = this.rotL(h);
|
|
333
|
-
this.head = h;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
return h;
|
|
337
|
-
};
|
|
338
|
-
|
|
339
|
-
Mat.BST.prototype.joinLR = function (a, b) {
|
|
340
|
-
if (this.isNil(b)) {
|
|
341
|
-
return a;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
b = this.partR(b, 0);
|
|
345
|
-
b.l = a;
|
|
346
|
-
this.fixN(b);
|
|
347
|
-
return b;
|
|
348
|
-
};
|
|
349
|
-
|
|
350
|
-
Mat.BST.prototype.deleteR = function (h, v) {
|
|
351
|
-
var x,
|
|
352
|
-
t = h.item;
|
|
353
|
-
|
|
354
|
-
if (this.isNil(h)) {
|
|
355
|
-
return this.z;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
if (v < t) {
|
|
359
|
-
h.l = this.deleteR(h.l, v);
|
|
360
|
-
}
|
|
361
|
-
if (t < v) {
|
|
362
|
-
h.r = this.deleteR(h.r, v);
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
if (t === v) {
|
|
366
|
-
x = h;
|
|
367
|
-
|
|
368
|
-
if (this.randomized) {
|
|
369
|
-
h = this.joinRandLR(h.l, h.r);
|
|
370
|
-
} else {
|
|
371
|
-
h = this.joinLR(h.l, h.r);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
if (this.isNil(h)) {
|
|
376
|
-
this.fixN(h);
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
return h;
|
|
380
|
-
};
|
|
381
|
-
|
|
382
|
-
Mat.BST.prototype.balanceR = function (h) {
|
|
383
|
-
if (h.N < 2) {
|
|
384
|
-
return h;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
h = this.partR(h, Math.floor(h.N / 2));
|
|
388
|
-
|
|
389
|
-
h.l = this.balanceR(h.l);
|
|
390
|
-
h.r = this.balanceR(h.r);
|
|
391
|
-
|
|
392
|
-
return h;
|
|
393
|
-
};
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
* Randomized Balnaced Binary Trees
|
|
397
|
-
*/
|
|
398
|
-
Mat.BST.prototype.insertRandR = function (h, item) {
|
|
399
|
-
var t = h.item;
|
|
400
|
-
|
|
401
|
-
if (this.isNil(h)) {
|
|
402
|
-
return this.newNode(item, this.z, this.z, 1);
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
if (Math.random() < 1 / (h.N + 1)) {
|
|
406
|
-
return this.insertT(h, item);
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
if (item < t) {
|
|
410
|
-
h.l = this.insertRandR(h.l, item);
|
|
411
|
-
} else {
|
|
412
|
-
h.r = this.insertRandR(h.r, item);
|
|
413
|
-
}
|
|
414
|
-
h.N++;
|
|
415
|
-
|
|
416
|
-
return h;
|
|
417
|
-
};
|
|
418
|
-
|
|
419
|
-
Mat.BST.prototype.joinRandR = function (a, b) {
|
|
420
|
-
if (this.isNil(a)) {
|
|
421
|
-
return b;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
b = this.insertRandR(b, a.item);
|
|
425
|
-
b.l = this.joinRand(a.l, b.l);
|
|
426
|
-
b.r = this.joinRand(a.r, b.r);
|
|
427
|
-
|
|
428
|
-
this.fixN(b);
|
|
429
|
-
|
|
430
|
-
return b;
|
|
431
|
-
};
|
|
432
|
-
|
|
433
|
-
Mat.BST.prototype.joinRandLR = function (a, b) {
|
|
434
|
-
if (this.isNil(a)) {
|
|
435
|
-
return b;
|
|
436
|
-
}
|
|
437
|
-
if (this.isNil(b)) {
|
|
438
|
-
return a;
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
if (Math.random() / (1 / (a.N + b.N) + 1) < a.N) {
|
|
442
|
-
a.r = this.joinRandLR(a.r, b);
|
|
443
|
-
return a;
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
b.l = this.joinRandLR(a, b.l);
|
|
447
|
-
return b;
|
|
448
|
-
};
|
|
449
|
-
|
|
450
|
-
/**
|
|
451
|
-
* Test output
|
|
452
|
-
*/
|
|
453
|
-
Mat.BST.prototype.printnode = function (node, hgt) {
|
|
454
|
-
var i,
|
|
455
|
-
t = "";
|
|
456
|
-
|
|
457
|
-
for (i = 0; i < hgt; i++) {
|
|
458
|
-
t += " ";
|
|
459
|
-
}
|
|
460
|
-
t += "(" + node.item + "," + node.N + ")";
|
|
461
|
-
// console.log(t);
|
|
462
|
-
};
|
|
463
|
-
|
|
464
|
-
Mat.BST.prototype.showR = function (x, hgt) {
|
|
465
|
-
if (this.isNil(x)) {
|
|
466
|
-
this.printnode(x, hgt);
|
|
467
|
-
return;
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
this.showR(x.r, hgt + 1);
|
|
471
|
-
this.printnode(x, hgt);
|
|
472
|
-
this.showR(x.l, hgt + 1);
|
|
473
|
-
};
|
|
474
|
-
|
|
475
|
-
export default Mat.BST;
|
package/src/unused/heap.js
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2008-2026
|
|
3
|
-
Matthias Ehmann,
|
|
4
|
-
Michael Gerhaeuser,
|
|
5
|
-
Carsten Miller,
|
|
6
|
-
Bianca Valentin,
|
|
7
|
-
Alfred Wassermann,
|
|
8
|
-
Peter Wilfahrt
|
|
9
|
-
|
|
10
|
-
This file is part of JSXGraph.
|
|
11
|
-
|
|
12
|
-
JSXGraph is free software dual licensed under the GNU LGPL or MIT License.
|
|
13
|
-
|
|
14
|
-
You can redistribute it and/or modify it under the terms of the
|
|
15
|
-
|
|
16
|
-
* GNU Lesser General Public License as published by
|
|
17
|
-
the Free Software Foundation, either version 3 of the License, or
|
|
18
|
-
(at your option) any later version
|
|
19
|
-
OR
|
|
20
|
-
* MIT License: https://github.com/jsxgraph/jsxgraph/blob/master/LICENSE.MIT
|
|
21
|
-
|
|
22
|
-
JSXGraph is distributed in the hope that it will be useful,
|
|
23
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
24
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
25
|
-
GNU Lesser General Public License for more details.
|
|
26
|
-
|
|
27
|
-
You should have received a copy of the GNU Lesser General Public License and
|
|
28
|
-
the MIT License along with JSXGraph. If not, see <https://www.gnu.org/licenses/>
|
|
29
|
-
and <https://opensource.org/licenses/MIT/>.
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/*global JXG:true, define: true*/
|
|
33
|
-
/*jslint nomen: true, plusplus: true*/
|
|
34
|
-
|
|
35
|
-
import Mat from "./math.js";
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Instantiate a new heap.
|
|
39
|
-
* Elements of the heap are objects (node) with a property `v`.
|
|
40
|
-
*
|
|
41
|
-
* The heap nodes are stored in a JavaScript array.
|
|
42
|
-
*
|
|
43
|
-
* @name JXG.Math.Heap
|
|
44
|
-
* @exports Mat.Heap as JXG.Math.Heap
|
|
45
|
-
*
|
|
46
|
-
* @constructor
|
|
47
|
-
*/
|
|
48
|
-
Mat.Heap = function () {
|
|
49
|
-
this.pq = [];
|
|
50
|
-
this.N = 0;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Clear the heap, i.e. remove all nodes.
|
|
55
|
-
*/
|
|
56
|
-
Mat.Heap.prototype.empty = function () {
|
|
57
|
-
this.pq = [];
|
|
58
|
-
this.N = 0;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Insert element `node`into heap. An element is an object having at least the property `v`.
|
|
63
|
-
* @param {Object} node
|
|
64
|
-
*/
|
|
65
|
-
Mat.Heap.prototype.insert = function (node) {
|
|
66
|
-
this.pq[this.N] = node;
|
|
67
|
-
this.N++;
|
|
68
|
-
this.fixUp(this.N);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Remove and return largest node in heap.
|
|
73
|
-
*
|
|
74
|
-
* @returns largest (in respect to property `v`) node
|
|
75
|
-
*/
|
|
76
|
-
Mat.Heap.prototype.delmax = function () {
|
|
77
|
-
this.exchange(0, this.N - 1);
|
|
78
|
-
this.fixDown(0, this.N - 1);
|
|
79
|
-
this.N--;
|
|
80
|
-
|
|
81
|
-
return this.pq[this.N];
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Restore heap properties from position k, i.e. positions < k.
|
|
86
|
-
* @param {Number} k
|
|
87
|
-
* @private
|
|
88
|
-
*/
|
|
89
|
-
Mat.Heap.prototype.fixUp = function (k) {
|
|
90
|
-
var i = k - 1;
|
|
91
|
-
|
|
92
|
-
while (i > 0 && this.pq[Math.floor(i / 2)].v < this.pq[i].v) {
|
|
93
|
-
this.exchange(Math.floor(i / 2), i);
|
|
94
|
-
i = Math.floor(i / 2);
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Restore heap properties between positions k and N.
|
|
100
|
-
* @param {Number} k
|
|
101
|
-
* @param {Number} N
|
|
102
|
-
* @private
|
|
103
|
-
*/
|
|
104
|
-
Mat.Heap.prototype.fixDown = function (k, N) {
|
|
105
|
-
var j,
|
|
106
|
-
i = k;
|
|
107
|
-
|
|
108
|
-
while (2 * i < N) {
|
|
109
|
-
j = 2 * i;
|
|
110
|
-
|
|
111
|
-
if (j < N && this.pq[j].v < this.pq[j + 1].v) {
|
|
112
|
-
j++;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (this.pq[i].v >= this.pq[j].v) {
|
|
116
|
-
break;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
this.exchange(i, j);
|
|
120
|
-
i = j;
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Swap heap elements at position i and j
|
|
126
|
-
* @param {Number} i
|
|
127
|
-
* @param {Number} j
|
|
128
|
-
*/
|
|
129
|
-
Mat.Heap.prototype.exchange = function (i, j) {
|
|
130
|
-
var t = this.pq[i];
|
|
131
|
-
this.pq[i] = this.pq[j];
|
|
132
|
-
this.pq[j] = t;
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
export default Mat.Heap;
|