function Map(){
	this.jsjava_class="jsjava.util.Map";
    this.capacity=50;
    this.size=0;
    this.span=10;
    this.elements=new Array(this.capacity);
}

/*
 * Increases the capacity of and internally reorganizes this 
 * hashtable, in order to accommodate and access its entries 
 * more efficiently.
 */
Map.prototype.recapacity=function(){
    if(this.capacity-this.size<10){
     this.capacity+=this.span;
     var oldElements=this.elements;
        this.elements=new Array(this.capacity); 
        for(var i=0;i<this.size;i++){
            this.elements[i]=oldElements[i]; 
        }
    }
};

/*
 * Removes all mappings from this map 
 */
Map.prototype.clear=function(){
    this.capacity=50;
    this.size=0;
    this.elements=new Array(this.capacity); 
};

/*
 * Associates the specified value with the specified key in this map 
 * param pname
 * param pvalue 
 */
Map.prototype.put=function (pname,pvalue){
    this.recapacity();
    if(this.containsKey(pname)){
        for(var i=0;i<this.size;i++){
            var elem=this.elements[i];
            if(elem[0]==pname){
                elem[1]=pvalue;
                return;
            } 
        } 
    }
    this.elements[this.size++]=[pname,pvalue];
   
};

/*
 * Returns the value to which this map maps the specified key. 
 * param pname
 */
Map.prototype.get=function (pname){
    for(var i=0;i<this.size;i++){
        var elem=this.elements[i];
        if(elem[0]==pname){
            return elem[1]; 
        } 
    }
};

/*
 * Returns true if this map contains a mapping for the specified key.
 * param pname
 */
Map.prototype.containsKey=function(pname){
    if(this.get(pname)==undefined){
        return false; 
    }
    return true;
};

/*
 * Returns true if this map maps one or more keys to the specified value.
 * param pname
 */
Map.prototype.containsValue=function (pvalue){
    for(var i=0;i<this.size;i++){
        var elem=this.elements[i];
        if(elem[1]==pvalue){
            return true;
        } 
    }
    return false;
};

/*
 * Returns a array view of the values contained in this map.
 */
Map.prototype.values=function (){
    var values=new Array(this.size);
    for(var i=0;i<this.size;i++){
        var elem=this.elements[i];
        values[i]=elem[1]; 
    } 
    return values;
};

/*
 * Returns a set view of the mappings contained in this map.
 */
Map.prototype.entrySet=function (){
    return this.elements; 
};

/*
 * Returns true if this map contains no key-value mappings.
 */
Map.prototype.isEmpty=function (){
    return this.size==0; 
};

/*
 * Returns an array of the keys in this map.
 */
Map.prototype.keys=function (){
    var keys=new Array(this.size);
    for(var i=0;i<this.size;i++){
        var elem=this.elements[i];
        keys[i]=elem[0]; 
    } 
    return keys;
};

/*
 * Returns the number of keys in this map.
 */
Map.prototype.getSize=function (){
    return this.size; 
};

/*
 * Removes the key (and its corresponding value) from this map.
 * param key
 */
Map.prototype.remove=function (key){
    if(this.containsKey(key)){
        var oldElems=this.elements;
        var oldSize=this.size;
        this.elements=new Array(this.capacity);
        this.size=0;
        for(var i=0;i<oldSize;i++){
            var oldElem=oldElems[i];
            if(oldElem[0]!=key){
                this.put(oldElem[0],oldElem[1]); 
            } 
        } 
    }
};

/*
 * add a array to the map
 * param arr
 */
Map.prototype.addArray=function (arr){
    if(arr!=null&&arr.length>0){
        for(var i=0;i<arr.length;i++){
            this.put(arr[i][0],arr[i][1]); 
        } 
    } 
};

/*
 * add a nmap to the map
 * param nmap
 */
Map.prototype.addMap=function (nmap){
    if(nmap!=null&&nmap.size()>0){
        var keys=nmap.keys();
        for(var i=0;i<keys.length;i++){
            this.put(keys[i],nmap.get(keys[i])); 
        } 
    } 
};

/*
 * Returns a string representation of this Map 
 * object in the form of a set of entries, enclosed 
 * in braces and separated by the ASCII characters ", " 
 * (comma and space).
 */
Map.prototype.toString=function (){
    return this.elements.toString(); 
};
