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

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

// Override
N
nem035 已提交
9
Array1DTracer.prototype._setData = function(D) {
J
minor  
Jason Park 已提交
10
    return Array2DTracer.prototype._setData.call(this, [D]);
J
Jason Park 已提交
11 12 13
};

// Override
N
nem035 已提交
14
Array1DTracer.prototype._notify = function(idx1, idx2) {
J
Jason Park 已提交
15 16 17 18 19
    if (idx2 === undefined) {
        Array2DTracer.prototype._notify.call(this, 0, idx1);
    } else {
        Array2DTracer.prototype._notify.call(this, 0, idx1, 0, idx2);
    }
J
Jason Park 已提交
20 21 22
};

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

31
// Override
N
nem035 已提交
32
Array1DTracer.prototype._selectSet = function(indexes) {
33
    var coords = [];
N
nem035 已提交
34 35 36 37 38
    indexes.forEach(function(index) {
        coords.push({
            x: 0,
            y: index
        });
39 40 41 42
    });
    Array2DTracer.prototype._selectSet.call(this, coords);
};

J
Jason Park 已提交
43
// Override
N
nem035 已提交
44
Array1DTracer.prototype._deselect = function(s, e) {
45 46
    if (e === undefined) {
        Array2DTracer.prototype._deselect.call(this, 0, s);
J
Jason Park 已提交
47
    } else {
48
        Array2DTracer.prototype._deselectRow.call(this, 0, s, e);
J
Jason Park 已提交
49 50 51 52
    }
};

// Override
N
nem035 已提交
53
Array1DTracer.prototype._deselectSet = function(indexes) {
54
    var coords = [];
N
nem035 已提交
55 56 57 58 59
    indexes.forEach(function(index) {
        coords.push({
            x: 0,
            y: index
        });
60 61
    });
    Array2DTracer.prototype._deselectSet.call(this, coords);
62 63 64 65 66 67 68 69 70
};

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];
    }
J
Jason Park 已提交
71
};