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

Array1DTracer.prototype = Object.create(Array2DTracer.prototype);
Array1DTracer.prototype.constructor = Array1DTracer;

J
Jason Park 已提交
8
var Array1D = {
N
nem035 已提交
9
    random: function(N, min, max) {
10
        return Array2D.random(1, N, min, max)[0];
N
nem035 已提交
11 12 13
    },
    randomSorted: function(N, min, max) {
        return Array2D.randomSorted(1, N, min, max)[0];
J
Jason Park 已提交
14
    }
J
Jason Park 已提交
15 16 17
};

// Override
N
nem035 已提交
18
Array1DTracer.prototype._setData = function(D) {
J
minor  
Jason Park 已提交
19
    return Array2DTracer.prototype._setData.call(this, [D]);
J
Jason Park 已提交
20 21 22
};

// Override
N
nem035 已提交
23
Array1DTracer.prototype._notify = function(idx1, idx2) {
J
Jason Park 已提交
24 25 26 27 28
    if (idx2 === undefined) {
        Array2DTracer.prototype._notify.call(this, 0, idx1);
    } else {
        Array2DTracer.prototype._notify.call(this, 0, idx1, 0, idx2);
    }
J
Jason Park 已提交
29 30 31
};

// Override
N
nem035 已提交
32
Array1DTracer.prototype._select = function(s, e) {
33 34
    if (e === undefined) {
        Array2DTracer.prototype._select.call(this, 0, s);
J
Jason Park 已提交
35
    } else {
36
        Array2DTracer.prototype._selectRow.call(this, 0, s, e);
J
Jason Park 已提交
37 38 39
    }
};

40
// Override
N
nem035 已提交
41
Array1DTracer.prototype._selectSet = function(indexes) {
42
    var coords = [];
N
nem035 已提交
43 44 45 46 47
    indexes.forEach(function(index) {
        coords.push({
            x: 0,
            y: index
        });
48 49 50 51
    });
    Array2DTracer.prototype._selectSet.call(this, coords);
};

J
Jason Park 已提交
52
// Override
N
nem035 已提交
53
Array1DTracer.prototype._deselect = function(s, e) {
54 55
    if (e === undefined) {
        Array2DTracer.prototype._deselect.call(this, 0, s);
J
Jason Park 已提交
56
    } else {
57
        Array2DTracer.prototype._deselectRow.call(this, 0, s, e);
J
Jason Park 已提交
58 59 60 61
    }
};

// Override
N
nem035 已提交
62
Array1DTracer.prototype._deselectSet = function(indexes) {
63
    var coords = [];
N
nem035 已提交
64 65 66 67 68
    indexes.forEach(function(index) {
        coords.push({
            x: 0,
            y: index
        });
69 70
    });
    Array2DTracer.prototype._deselectSet.call(this, coords);
J
Jason Park 已提交
71
};