/**
* Selection Algorithm
* This function provide service for selection algorithm.
*
* @author : irfanudin ridho
* @email : irfan.ub@gmail.com
* @date : December 29, 2010
* @version : 1.0
*/
/**
* Constructor service
* @param data array of data
*/
function DataAlgorithm(data){
this.data = data;
}
/**
* function to get min value from the data
* @return min value of the data
*/
DataAlgorithm.prototype.getMinValue = function(){
* Selection Algorithm
* This function provide service for selection algorithm.
*
* @author : irfanudin ridho
* @email : irfan.ub@gmail.com
* @date : December 29, 2010
* @version : 1.0
*/
/**
* Constructor service
* @param data array of data
*/
function DataAlgorithm(data){
this.data = data;
}
/**
* function to get min value from the data
* @return min value of the data
*/
DataAlgorithm.prototype.getMinValue = function(){
return this.data[this.getMinValueIndex()];
};
/**
* function to get max value from the data
* @return max value of the data
*/
DataAlgorithm.prototype.getMaxValue = function(){
return this.data[this.getMaxValueIndex()];
};
/**
* function to get index of the min value
* @return number index of the min value
*/
DataAlgorithm.prototype.getMinValueIndex = function(){
var minIndex = this.data[0];
for(i=0;i<this.data.length;i++){
if(this.data[i+1]<this.data[minIndex]){
minIndex = i+1;
}
}
return minIndex;
};
/**
* method to get index of the max value
* @return number index of the max value
*/
DataAlgorithm.prototype.getMaxValueIndex = function(){
var maxIndex = this.data[0];
for(i=0;i<this.data.length;i++){
if(this.data[i+1]>this.data[maxIndex]){
maxIndex = i+1;
}
}
return maxIndex;
};
};
/**
* function to get max value from the data
* @return max value of the data
*/
DataAlgorithm.prototype.getMaxValue = function(){
return this.data[this.getMaxValueIndex()];
};
/**
* function to get index of the min value
* @return number index of the min value
*/
DataAlgorithm.prototype.getMinValueIndex = function(){
var minIndex = this.data[0];
for(i=0;i<this.data.length;i++){
if(this.data[i+1]<this.data[minIndex]){
minIndex = i+1;
}
}
return minIndex;
};
/**
* method to get index of the max value
* @return number index of the max value
*/
DataAlgorithm.prototype.getMaxValueIndex = function(){
var maxIndex = this.data[0];
for(i=0;i<this.data.length;i++){
if(this.data[i+1]>this.data[maxIndex]){
maxIndex = i+1;
}
}
return maxIndex;
};
No comments:
Post a Comment