/**
* An ADT of Map. This ADT will do functionality as
* An ADT of Map. This ADT will do functionality as
* the key value ADT.
*
* @author : irfanudin ridho
* @email : irfan.ub@gmail.com
* @date : December 31, 2010
* @version : 1.0
*/
/**
* A constructor service.
*/
function Map(){
this.key = new Array();
this.value = new Array();
}
/**
* A method to add an elements to the Map
*
* @param k string, number key element
* @param v string, number, boolean value element
*/
Map.prototype.add = function(k,v){
var len = this.key.length;
this.key[len] = k;
this.value[len] = v;
};
/**
* A method to get an element as suitable for the key
*
* @param k key of the element
* @return value as suitable for the key.
*/
Map.prototype.get = function(k){
var index = 0;
for(i=0;i<k.length;i++){
if(this.key[i]==k)
index = i;
}
return this.value[index];
};
*
* @author : irfanudin ridho
* @email : irfan.ub@gmail.com
* @date : December 31, 2010
* @version : 1.0
*/
/**
* A constructor service.
*/
function Map(){
this.key = new Array();
this.value = new Array();
}
/**
* A method to add an elements to the Map
*
* @param k string, number key element
* @param v string, number, boolean value element
*/
Map.prototype.add = function(k,v){
var len = this.key.length;
this.key[len] = k;
this.value[len] = v;
};
/**
* A method to get an element as suitable for the key
*
* @param k key of the element
* @return value as suitable for the key.
*/
Map.prototype.get = function(k){
var index = 0;
for(i=0;i<k.length;i++){
if(this.key[i]==k)
index = i;
}
return this.value[index];
};
No comments:
Post a Comment