array1d.js 1.7 KB
Newer Older
J
Jason Park 已提交
1 2 3 4
function Array1DTracer(module) {
    return Array2DTracer.call(this, module || Array1DTracer);
}

J
Jason Park 已提交
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
Array1DTracer.prototype = $.extend(true, Object.create(Array2DTracer.prototype), {
    constructor: Array1DTracer,
    _notify: function (idx1, idx2) {
        if (idx2 === undefined) {
            Array2DTracer.prototype._notify.call(this, 0, idx1);
        } else {
            Array2DTracer.prototype._notify.call(this, 0, idx1, 0, idx2);
        }
    },
    _select: function (s, e) {
        if (e === undefined) {
            Array2DTracer.prototype._select.call(this, 0, s);
        } else {
            Array2DTracer.prototype._selectRow.call(this, 0, s, e);
        }
    },
    _selectSet: function (indexes) {
        var coords = [];
        indexes.forEach(function (index) {
            coords.push({
                x: 0,
                y: index
            });
N
nem035 已提交
28
        });
J
Jason Park 已提交
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
        Array2DTracer.prototype._selectSet.call(this, coords);
    },
    _deselect: function (s, e) {
        if (e === undefined) {
            Array2DTracer.prototype._deselect.call(this, 0, s);
        } else {
            Array2DTracer.prototype._deselectRow.call(this, 0, s, e);
        }
    },
    _deselectSet: function (indexes) {
        var coords = [];
        indexes.forEach(function (index) {
            coords.push({
                x: 0,
                y: index
            });
N
nem035 已提交
45
        });
J
Jason Park 已提交
46
        Array2DTracer.prototype._deselectSet.call(this, coords);
J
Jason Park 已提交
47 48 49
    },
    setData: function (D) {
        return Array2DTracer.prototype.setData.call(this, [D]);
J
Jason Park 已提交
50 51
    }
});
52 53

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