terra-route 0.0.11 → 0.0.12
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/README.md +2 -12
- package/dist/terra-route.cjs +1 -1
- package/dist/terra-route.cjs.map +1 -1
- package/dist/terra-route.d.ts +1 -2
- package/dist/terra-route.modern.js +1 -1
- package/dist/terra-route.modern.js.map +1 -1
- package/dist/terra-route.module.js +1 -1
- package/dist/terra-route.module.js.map +1 -1
- package/dist/terra-route.umd.js +1 -1
- package/dist/terra-route.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/terra-route.ts +1 -2
- package/src/graph/graph.spec.ts +0 -238
- package/src/graph/graph.ts +0 -212
- package/src/graph/methods/bounding-box.spec.ts +0 -199
- package/src/graph/methods/bounding-box.ts +0 -85
- package/src/graph/methods/connected.spec.ts +0 -219
- package/src/graph/methods/connected.ts +0 -168
- package/src/graph/methods/duplicates.spec.ts +0 -161
- package/src/graph/methods/duplicates.ts +0 -117
- package/src/graph/methods/leaf.spec.ts +0 -224
- package/src/graph/methods/leaf.ts +0 -88
- package/src/graph/methods/nodes.spec.ts +0 -317
- package/src/graph/methods/nodes.ts +0 -77
- package/src/graph/methods/spatial-index/geokdbush.spec.ts +0 -86
- package/src/graph/methods/spatial-index/geokdbush.ts +0 -189
- package/src/graph/methods/spatial-index/kdbush.spec.ts +0 -67
- package/src/graph/methods/spatial-index/kdbush.ts +0 -189
- package/src/graph/methods/spatial-index/tinyqueue.spec.ts +0 -51
- package/src/graph/methods/spatial-index/tinyqueue.ts +0 -108
- package/src/graph/methods/unify.spec.ts +0 -475
- package/src/graph/methods/unify.ts +0 -132
- package/src/graph/methods/unique.spec.ts +0 -65
- package/src/graph/methods/unique.ts +0 -69
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { KDBush } from './kdbush';
|
|
2
|
-
|
|
3
|
-
describe('KDBush', () => {
|
|
4
|
-
const points = [
|
|
5
|
-
[0, 0], [1, 1], [2, 2], [3, 3],
|
|
6
|
-
[1, 0], [0, 1], [3, 2], [2, 3]
|
|
7
|
-
];
|
|
8
|
-
|
|
9
|
-
it('should build an index correctly', () => {
|
|
10
|
-
const index = new KDBush(points.length);
|
|
11
|
-
for (const p of points) {
|
|
12
|
-
index.add(p[0], p[1]);
|
|
13
|
-
}
|
|
14
|
-
index.finish();
|
|
15
|
-
|
|
16
|
-
expect(index.ids.length).toBe(points.length);
|
|
17
|
-
expect(index.coords.length).toBe(points.length * 2);
|
|
18
|
-
// Check if ids are a permutation of 0..n-1
|
|
19
|
-
expect(Array.from(index.ids).sort((a, b) => a - b)).toEqual([0, 1, 2, 3, 4, 5, 6, 7]);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('should throw an error if finish is called with wrong number of points', () => {
|
|
23
|
-
const index = new KDBush(points.length);
|
|
24
|
-
index.add(0, 0);
|
|
25
|
-
expect(() => index.finish()).toThrow('Added 1 items when expected 8.');
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('should handle different array types', () => {
|
|
29
|
-
const index = new KDBush(points.length, 64, Float32Array);
|
|
30
|
-
for (const p of points) {
|
|
31
|
-
index.add(p[0], p[1]);
|
|
32
|
-
}
|
|
33
|
-
index.finish();
|
|
34
|
-
expect(index.coords).toBeInstanceOf(Float32Array);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('should throw on invalid numItems', () => {
|
|
38
|
-
expect(() => new KDBush(-1)).toThrow('Unexpected numItems value: -1.');
|
|
39
|
-
expect(() => new KDBush(NaN)).toThrow('Unexpected numItems value: NaN.');
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('should throw on invalid ArrayType', () => {
|
|
43
|
-
// @ts-expect-error
|
|
44
|
-
expect(() => new KDBush(1, 64, Array)).toThrow('Unexpected typed array class: function Array() { [native code] }');
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('should reconstruct an index from data', () => {
|
|
48
|
-
const index = new KDBush(points.length);
|
|
49
|
-
for (const p of points) {
|
|
50
|
-
index.add(p[0], p[1]);
|
|
51
|
-
}
|
|
52
|
-
index.finish();
|
|
53
|
-
|
|
54
|
-
const data = index.data;
|
|
55
|
-
const index2 = new KDBush(points.length, 64, Float64Array, data);
|
|
56
|
-
|
|
57
|
-
expect(index2.ids).toEqual(index.ids);
|
|
58
|
-
expect(index2.coords).toEqual(index.coords);
|
|
59
|
-
expect(index2.numItems).toBe(index.numItems);
|
|
60
|
-
expect(index2.nodeSize).toBe(index.nodeSize);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('should use Uint32Array for large number of items', () => {
|
|
64
|
-
const index = new KDBush(70000);
|
|
65
|
-
expect(index.ids).toBeInstanceOf(Uint32Array);
|
|
66
|
-
});
|
|
67
|
-
});
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
// Adapted from https://github.com/mourner/kdbush
|
|
2
|
-
|
|
3
|
-
// ISC License
|
|
4
|
-
|
|
5
|
-
// Copyright (c) 2018, Vladimir Agafonkin
|
|
6
|
-
|
|
7
|
-
// Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
8
|
-
// with or without fee is hereby granted, provided that the above copyright notice
|
|
9
|
-
// and this permission notice appear in all copies.
|
|
10
|
-
|
|
11
|
-
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
12
|
-
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
13
|
-
// FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
14
|
-
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
15
|
-
// OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
16
|
-
// TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
17
|
-
// THIS SOFTWARE.
|
|
18
|
-
|
|
19
|
-
const ARRAY_TYPES = [
|
|
20
|
-
Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array,
|
|
21
|
-
Int32Array, Uint32Array, Float32Array, Float64Array
|
|
22
|
-
];
|
|
23
|
-
|
|
24
|
-
const VERSION = 1;
|
|
25
|
-
const HEADER_SIZE = 8;
|
|
26
|
-
|
|
27
|
-
export class KDBush {
|
|
28
|
-
public data: ArrayBuffer;
|
|
29
|
-
public ids: Uint16Array | Uint32Array;
|
|
30
|
-
public coords: InstanceType<TypedArrayConstructor>;
|
|
31
|
-
private _pos: number;
|
|
32
|
-
private _finished: boolean;
|
|
33
|
-
public numItems: number;
|
|
34
|
-
public nodeSize: number;
|
|
35
|
-
private ArrayType: TypedArrayConstructor;
|
|
36
|
-
private IndexArrayType: typeof Uint16Array | typeof Uint32Array;
|
|
37
|
-
|
|
38
|
-
constructor(
|
|
39
|
-
numItems: number,
|
|
40
|
-
nodeSize: number = 64,
|
|
41
|
-
ArrayType: TypedArrayConstructor = Float64Array,
|
|
42
|
-
data?: ArrayBuffer
|
|
43
|
-
) {
|
|
44
|
-
if (isNaN(numItems) || numItems < 0) {
|
|
45
|
-
throw new Error(`Unexpected numItems value: ${numItems}.`);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
this.numItems = numItems;
|
|
49
|
-
this.nodeSize = Math.min(Math.max(nodeSize, 2), 65535);
|
|
50
|
-
this.ArrayType = ArrayType;
|
|
51
|
-
this.IndexArrayType = numItems < 65536 ? Uint16Array : Uint32Array;
|
|
52
|
-
|
|
53
|
-
const arrayTypeIndex = ARRAY_TYPES.indexOf(this.ArrayType);
|
|
54
|
-
const coordsByteSize = numItems * 2 * this.ArrayType.BYTES_PER_ELEMENT;
|
|
55
|
-
const idsByteSize = numItems * this.IndexArrayType.BYTES_PER_ELEMENT;
|
|
56
|
-
const padCoords = (8 - idsByteSize % 8) % 8;
|
|
57
|
-
|
|
58
|
-
if (arrayTypeIndex < 0) {
|
|
59
|
-
throw new Error(`Unexpected typed array class: ${ArrayType}.`);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (data) {
|
|
63
|
-
this.data = data;
|
|
64
|
-
this.ids = new (this.IndexArrayType as any)(this.data, HEADER_SIZE, numItems);
|
|
65
|
-
this.coords = new (this.ArrayType as any)(this.data, HEADER_SIZE + idsByteSize + padCoords, numItems * 2);
|
|
66
|
-
this._pos = numItems * 2;
|
|
67
|
-
this._finished = true;
|
|
68
|
-
} else {
|
|
69
|
-
this.data = new ArrayBuffer(HEADER_SIZE + coordsByteSize + idsByteSize + padCoords);
|
|
70
|
-
this.ids = new (this.IndexArrayType as any)(this.data, HEADER_SIZE, numItems);
|
|
71
|
-
this.coords = new (this.ArrayType as any)(this.data, HEADER_SIZE + idsByteSize + padCoords, numItems * 2);
|
|
72
|
-
this._pos = 0;
|
|
73
|
-
this._finished = false;
|
|
74
|
-
|
|
75
|
-
new Uint8Array(this.data, 0, 2).set([0xdb, (VERSION << 4) + arrayTypeIndex]);
|
|
76
|
-
new Uint16Array(this.data, 2, 1)[0] = this.nodeSize;
|
|
77
|
-
new Uint32Array(this.data, 4, 1)[0] = this.numItems;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
add(x: number, y: number): number {
|
|
82
|
-
const index = this._pos >> 1;
|
|
83
|
-
this.ids[index] = index;
|
|
84
|
-
this.coords[this._pos++] = x;
|
|
85
|
-
this.coords[this._pos++] = y;
|
|
86
|
-
return index;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
finish(): this {
|
|
90
|
-
const numAdded = this._pos >> 1;
|
|
91
|
-
if (numAdded !== this.numItems) {
|
|
92
|
-
throw new Error(`Added ${numAdded} items when expected ${this.numItems}.`);
|
|
93
|
-
}
|
|
94
|
-
sort(this.ids, this.coords, this.nodeSize, 0, this.numItems - 1, 0);
|
|
95
|
-
this._finished = true;
|
|
96
|
-
return this;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
type TypedArrayConstructor =
|
|
101
|
-
Int8ArrayConstructor | Uint8ArrayConstructor | Uint8ClampedArrayConstructor |
|
|
102
|
-
Int16ArrayConstructor | Uint16ArrayConstructor |
|
|
103
|
-
Int32ArrayConstructor | Uint32ArrayConstructor |
|
|
104
|
-
Float32ArrayConstructor | Float64ArrayConstructor;
|
|
105
|
-
|
|
106
|
-
function sort(
|
|
107
|
-
ids: Uint16Array | Uint32Array,
|
|
108
|
-
coords: InstanceType<TypedArrayConstructor>,
|
|
109
|
-
nodeSize: number,
|
|
110
|
-
left: number,
|
|
111
|
-
right: number,
|
|
112
|
-
axis: number
|
|
113
|
-
): void {
|
|
114
|
-
if (right - left <= nodeSize) return;
|
|
115
|
-
const m = (left + right) >> 1;
|
|
116
|
-
select(ids, coords, m, left, right, axis);
|
|
117
|
-
sort(ids, coords, nodeSize, left, m - 1, 1 - axis);
|
|
118
|
-
sort(ids, coords, nodeSize, m + 1, right, 1 - axis);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function select(
|
|
122
|
-
ids: Uint16Array | Uint32Array,
|
|
123
|
-
coords: InstanceType<TypedArrayConstructor>,
|
|
124
|
-
k: number,
|
|
125
|
-
left: number,
|
|
126
|
-
right: number,
|
|
127
|
-
axis: number
|
|
128
|
-
): void {
|
|
129
|
-
while (right > left) {
|
|
130
|
-
if (right - left > 600) {
|
|
131
|
-
const n = right - left + 1;
|
|
132
|
-
const m = k - left + 1;
|
|
133
|
-
const z = Math.log(n);
|
|
134
|
-
const s = 0.5 * Math.exp(2 * z / 3);
|
|
135
|
-
const sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);
|
|
136
|
-
const newLeft = Math.max(left, Math.floor(k - m * s / n + sd));
|
|
137
|
-
const newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));
|
|
138
|
-
select(ids, coords, k, newLeft, newRight, axis);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
const t = coords[2 * k + axis];
|
|
142
|
-
let i = left;
|
|
143
|
-
let j = right;
|
|
144
|
-
|
|
145
|
-
swapItem(ids, coords, left, k);
|
|
146
|
-
if (coords[2 * right + axis] > t) {
|
|
147
|
-
swapItem(ids, coords, left, right);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
while (i < j) {
|
|
151
|
-
swapItem(ids, coords, i, j);
|
|
152
|
-
i++;
|
|
153
|
-
j--;
|
|
154
|
-
while (coords[2 * i + axis] < t) i++;
|
|
155
|
-
while (coords[2 * j + axis] > t) j--;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (coords[2 * left + axis] === t) {
|
|
159
|
-
swapItem(ids, coords, left, j);
|
|
160
|
-
} else {
|
|
161
|
-
j++;
|
|
162
|
-
swapItem(ids, coords, j, right);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if (j <= k) left = j + 1;
|
|
166
|
-
if (k <= j) right = j - 1;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function swapItem(
|
|
171
|
-
ids: Uint16Array | Uint32Array,
|
|
172
|
-
coords: InstanceType<TypedArrayConstructor>,
|
|
173
|
-
i: number,
|
|
174
|
-
j: number
|
|
175
|
-
): void {
|
|
176
|
-
swap(ids, i, j);
|
|
177
|
-
swap(coords, 2 * i, 2 * j);
|
|
178
|
-
swap(coords, 2 * i + 1, 2 * j + 1);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function swap<T extends Uint16Array | Uint32Array | Float32Array | Float64Array | Int8Array | Int16Array | Int32Array | Uint8Array | Uint8ClampedArray>(
|
|
182
|
-
arr: T,
|
|
183
|
-
i: number,
|
|
184
|
-
j: number
|
|
185
|
-
): void {
|
|
186
|
-
const tmp = arr[i];
|
|
187
|
-
arr[i] = arr[j];
|
|
188
|
-
arr[j] = tmp;
|
|
189
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import TinyQueue from './tinyqueue';
|
|
2
|
-
|
|
3
|
-
describe('TinyQueue', () => {
|
|
4
|
-
it('should create a queue', () => {
|
|
5
|
-
const queue = new TinyQueue();
|
|
6
|
-
expect(queue).toBeDefined();
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
it('should push and pop items', () => {
|
|
10
|
-
const queue = new TinyQueue<{ value: number }>([], (a, b) => a.value - b.value);
|
|
11
|
-
queue.push({ value: 3 });
|
|
12
|
-
queue.push({ value: 1 });
|
|
13
|
-
queue.push({ value: 2 });
|
|
14
|
-
|
|
15
|
-
expect(queue.pop()?.value).toBe(1);
|
|
16
|
-
expect(queue.pop()?.value).toBe(2);
|
|
17
|
-
expect(queue.pop()?.value).toBe(3);
|
|
18
|
-
expect(queue.pop()).toBeUndefined();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('should peek at the top item', () => {
|
|
22
|
-
const queue = new TinyQueue<{ value: number }>([], (a, b) => a.value - b.value);
|
|
23
|
-
queue.push({ value: 3 });
|
|
24
|
-
queue.push({ value: 1 });
|
|
25
|
-
queue.push({ value: 2 });
|
|
26
|
-
|
|
27
|
-
expect(queue.peek()?.value).toBe(1);
|
|
28
|
-
queue.pop();
|
|
29
|
-
expect(queue.peek()?.value).toBe(2);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('should handle an empty queue', () => {
|
|
33
|
-
const queue = new TinyQueue();
|
|
34
|
-
expect(queue.pop()).toBeUndefined();
|
|
35
|
-
expect(queue.peek()).toBeUndefined();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('should handle initial data', () => {
|
|
39
|
-
const data = [{ value: 3 }, { value: 1 }, { value: 2 }];
|
|
40
|
-
const queue = new TinyQueue<{ value: number }>(data, (a, b) => a.value - b.value);
|
|
41
|
-
expect(queue.pop()?.value).toBe(1);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('should use default comparator', () => {
|
|
45
|
-
const queue = new TinyQueue<number>();
|
|
46
|
-
queue.push(3);
|
|
47
|
-
queue.push(1);
|
|
48
|
-
queue.push(2);
|
|
49
|
-
expect(queue.pop()).toBe(1);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
// Adapted from https://github.com/mourner/kdbush
|
|
2
|
-
|
|
3
|
-
// ISC License
|
|
4
|
-
|
|
5
|
-
// Copyright (c) 2017, Vladimir Agafonkin
|
|
6
|
-
|
|
7
|
-
// Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
8
|
-
// with or without fee is hereby granted, provided that the above copyright notice
|
|
9
|
-
// and this permission notice appear in all copies.
|
|
10
|
-
|
|
11
|
-
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
12
|
-
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
13
|
-
// FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
14
|
-
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
15
|
-
// OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
16
|
-
// TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
17
|
-
// THIS SOFTWARE.
|
|
18
|
-
|
|
19
|
-
export default class TinyQueue<T> {
|
|
20
|
-
|
|
21
|
-
private data: T[];
|
|
22
|
-
public length: number;
|
|
23
|
-
private compare: (a: T, b: T) => number;
|
|
24
|
-
|
|
25
|
-
constructor(
|
|
26
|
-
data: T[] = [],
|
|
27
|
-
compare: (a: T, b: T) => number = (a, b) =>
|
|
28
|
-
a < b ? -1 : a > b ? 1 : 0
|
|
29
|
-
) {
|
|
30
|
-
this.data = data;
|
|
31
|
-
this.length = this.data.length;
|
|
32
|
-
this.compare = compare;
|
|
33
|
-
|
|
34
|
-
if (this.length > 0) {
|
|
35
|
-
for (let i = (this.length >> 1) - 1; i >= 0; i--) {
|
|
36
|
-
this._down(i);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
push(item: T): void {
|
|
42
|
-
this.data.push(item);
|
|
43
|
-
this._up(this.length++);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
pop(): T | undefined {
|
|
47
|
-
if (this.length === 0) {
|
|
48
|
-
return undefined;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const top = this.data[0];
|
|
52
|
-
const bottom = this.data.pop() as T;
|
|
53
|
-
|
|
54
|
-
this.length--;
|
|
55
|
-
|
|
56
|
-
if (this.length > 0) {
|
|
57
|
-
this.data[0] = bottom;
|
|
58
|
-
this._down(0);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return top;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
peek(): T | undefined {
|
|
65
|
-
return this.data[0];
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
private _up(pos: number): void {
|
|
69
|
-
const { data, compare } = this;
|
|
70
|
-
const item = data[pos];
|
|
71
|
-
|
|
72
|
-
while (pos > 0) {
|
|
73
|
-
const parent = (pos - 1) >> 1;
|
|
74
|
-
const current = data[parent];
|
|
75
|
-
if (compare(item, current) >= 0) {
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
data[pos] = current;
|
|
79
|
-
pos = parent;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
data[pos] = item;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
private _down(pos: number): void {
|
|
86
|
-
const { data, compare } = this;
|
|
87
|
-
const halfLength = this.length >> 1;
|
|
88
|
-
const item = data[pos];
|
|
89
|
-
|
|
90
|
-
while (pos < halfLength) {
|
|
91
|
-
let bestChild = (pos << 1) + 1;
|
|
92
|
-
const right = bestChild + 1;
|
|
93
|
-
|
|
94
|
-
if (right < this.length && compare(data[right], data[bestChild]) < 0) {
|
|
95
|
-
bestChild = right;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (compare(data[bestChild], item) >= 0) {
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
data[pos] = data[bestChild];
|
|
103
|
-
pos = bestChild;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
data[pos] = item;
|
|
107
|
-
}
|
|
108
|
-
}
|