Skip to content

Commit 6f91d78

Browse files
committed
es6-style tracers
1 parent ad12091 commit 6f91d78

18 files changed

+2095
-1860
lines changed

algorithm/dp/pascal_triangle/pascal_triangle/data.js

-6
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,4 @@ for (var i = N - 1; i >= 0; i--) {
44
A[i] = new Array (N);
55
}
66

7-
for (var i = N - 1; i >= 0; i--) {
8-
for (var j = N - 1; j >= 0; j--) {
9-
A[i][j] = ' ';
10-
}
11-
}
12-
137
var tracer = new Array2DTracer ('Pascal\'s Triangle')._setData(A);

js/app/constructor.js

-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ const {
99
hideLoadingSlider
1010
} = require('../dom/loading_slider');
1111

12-
const {
13-
getFileDir
14-
} = require('../utils');
15-
1612
const Cache = require('./cache');
1713

1814
const state = {

js/module/data/array2d.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ const random = (N, M, min, max) => {
1313
return D;
1414
};
1515

16-
const randomSorted = (N, M, min, max)=> {
17-
return this.random(N, M, min, max).map(function (arr) {
16+
const randomSorted = (N, M, min, max) => {
17+
return random(N, M, min, max).map(function (arr) {
1818
return arr.sort(function (a, b) {
1919
return a - b;
2020
});

js/module/tracer/array1d.js

+29-23
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,45 @@
11
const Array2DTracer = require('./array2d');
22

3-
function Array1DTracer() {
4-
return Array2DTracer.apply(this, arguments);
5-
}
3+
class Array1DTracer extends Array2DTracer {
4+
static getClassName() {
5+
return 'Array1DTracer';
6+
}
7+
8+
constructor(name) {
9+
super(name);
10+
}
611

7-
Array1DTracer.prototype = $.extend(true, Object.create(Array2DTracer.prototype), {
8-
constructor: Array1DTracer,
9-
name: "Array1DTracer",
10-
_notify: function (idx, v) {
11-
Array2DTracer.prototype._notify.call(this, 0, idx, v);
12+
_notify(idx, v) {
13+
super._notify(0, idx, v);
1214
return this;
13-
},
14-
_denotify: function (idx) {
15-
Array2DTracer.prototype._denotify.call(this, 0, idx);
15+
}
16+
17+
_denotify(idx) {
18+
super._denotify(0, idx);
1619
return this;
17-
},
18-
_select: function (s, e) {
20+
}
21+
22+
_select(s, e) {
1923
if (e === undefined) {
20-
Array2DTracer.prototype._select.call(this, 0, s);
24+
super._select(0, s);
2125
} else {
22-
Array2DTracer.prototype._selectRow.call(this, 0, s, e);
26+
super._selectRow(0, s, e);
2327
}
2428
return this;
25-
},
26-
_deselect: function (s, e) {
29+
}
30+
31+
_deselect(s, e) {
2732
if (e === undefined) {
28-
Array2DTracer.prototype._deselect.call(this, 0, s);
33+
super._deselect(0, s);
2934
} else {
30-
Array2DTracer.prototype._deselectRow.call(this, 0, s, e);
35+
super._deselectRow(0, s, e);
3136
}
3237
return this;
33-
},
34-
setData: function (D) {
35-
return Array2DTracer.prototype.setData.call(this, [D]);
3638
}
37-
});
39+
40+
setData(D) {
41+
return super.setData([D]);
42+
}
43+
}
3844

3945
module.exports = Array1DTracer;

0 commit comments

Comments
 (0)