forked from algorithm-visualizer/algorithm-visualizer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray1d.js
More file actions
71 lines (63 loc) · 1.79 KB
/
array1d.js
File metadata and controls
71 lines (63 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
function Array1DTracer(module) {
return Array2DTracer.call(this, module || Array1DTracer);
}
Array1DTracer.prototype = Object.create(Array2DTracer.prototype);
Array1DTracer.prototype.constructor = Array1DTracer;
// Override
Array1DTracer.prototype._setData = function(D) {
return Array2DTracer.prototype._setData.call(this, [D]);
};
// Override
Array1DTracer.prototype._notify = function(idx1, idx2) {
if (idx2 === undefined) {
Array2DTracer.prototype._notify.call(this, 0, idx1);
} else {
Array2DTracer.prototype._notify.call(this, 0, idx1, 0, idx2);
}
};
// Override
Array1DTracer.prototype._select = function(s, e) {
if (e === undefined) {
Array2DTracer.prototype._select.call(this, 0, s);
} else {
Array2DTracer.prototype._selectRow.call(this, 0, s, e);
}
};
// Override
Array1DTracer.prototype._selectSet = function(indexes) {
var coords = [];
indexes.forEach(function(index) {
coords.push({
x: 0,
y: index
});
});
Array2DTracer.prototype._selectSet.call(this, coords);
};
// Override
Array1DTracer.prototype._deselect = function(s, e) {
if (e === undefined) {
Array2DTracer.prototype._deselect.call(this, 0, s);
} else {
Array2DTracer.prototype._deselectRow.call(this, 0, s, e);
}
};
// Override
Array1DTracer.prototype._deselectSet = function(indexes) {
var coords = [];
indexes.forEach(function(index) {
coords.push({
x: 0,
y: index
});
});
Array2DTracer.prototype._deselectSet.call(this, coords);
};
var Array1D = {
random: function(N, min, max) {
return Array2D.random(1, N, min, max)[0];
},
randomSorted: function(N, min, max) {
return Array2D.randomSorted(1, N, min, max)[0];
}
};