var triplet = {
v: [undefined, undefined, undefined],
initTriplet: function (v1, v2, v3) {
this.v[0] = v1;
this.v[1] = v2;
this.v[2] = v3;
},
get: function (index) {
return this.v[index];
},
put: function (index, value) {
this.v[index] = value;
},
isAscending: function() {
return this.v[0] <= this.v[1] && this.v[1] <= this.v[2];
},
isDescending: function() {
return this.v[0] >= this.v[1] && this.v[1] >= this.v[2];
},
max: function() {
return Math.max.apply(null, this.v);
},
min: function() {
return Math.min.apply(null, this.v);
}
};
网友评论