array1d.js 1.6 KB
Newer Older
J
Jason Park 已提交
1 2
function Array1DTracer() {
    return Array2DTracer.apply(this, arguments);
J
Jason Park 已提交
3 4
}

J
Jason Park 已提交
5 6
Array1DTracer.prototype = $.extend(true, Object.create(Array2DTracer.prototype), {
    constructor: Array1DTracer,
7 8 9 10 11 12 13
    _notify: function (idx, v) {
        Array2DTracer.prototype._notify.call(this, 0, idx, v);
        return this;
    },
    _denotify: function (idx) {
        Array2DTracer.prototype._denotify.call(this, 0, idx);
        return this;
J
Jason Park 已提交
14 15 16 17 18 19 20
    },
    _select: function (s, e) {
        if (e === undefined) {
            Array2DTracer.prototype._select.call(this, 0, s);
        } else {
            Array2DTracer.prototype._selectRow.call(this, 0, s, e);
        }
21
        return this;
J
Jason Park 已提交
22 23 24 25 26 27 28
    },
    _deselect: function (s, e) {
        if (e === undefined) {
            Array2DTracer.prototype._deselect.call(this, 0, s);
        } else {
            Array2DTracer.prototype._deselectRow.call(this, 0, s, e);
        }
29
        return this;
J
Jason Park 已提交
30
    },
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
    _separate: function (idx) {
        this.manager.pushStep(this.capsule, {
            type: 'separate',
            x: 0,
            y: idx
        });
        return this;
    },
    _deseparate: function (idx) {
        this.manager.pushStep(this.capsule, {
            type: 'deseparate',
            x: 0,
            y: idx
        });
        return this;
    },
J
Jason Park 已提交
47 48
    setData: function (D) {
        return Array2DTracer.prototype.setData.call(this, [D]);
J
Jason Park 已提交
49 50
    }
});
51 52

var Array1D = {
J
Jason Park 已提交
53
    random: function (N, min, max) {
54 55
        return Array2D.random(1, N, min, max)[0];
    },
J
Jason Park 已提交
56
    randomSorted: function (N, min, max) {
57 58
        return Array2D.randomSorted(1, N, min, max)[0];
    }
J
Jason Park 已提交
59
};