 /**/ /* 
 2   name:       SimpleMap.js
 3   version:    1.0.0
 4   author:     ΝτΊ²Οθ
 5   date:       2006-09-06    
 6   Descript: This is a Map implement of JavaScript 
 7   remark:    
 8  */      
  // SimpleMap Object just like HashMap of Java 
   
	function  SimpleMap()  {     
      var  keys  =   new  Array();
      var  entrys  =   new  Array(); 
      this.type  =  'SimpleMap'; 
      
	  this .keySet  =   function ()  {
		return  keys;
	  } ;  

       this.entrySet  =   function ()  {
          return  entrys;
     } ; 
 }        
  
	// put a mapping relation in map 
   SimpleMap.prototype.put  =   function (key,entry)  { 
       if (key  !=   null  
           &&  key  !=  'undefined'
          &&  entry  !=   null 
           &&  entry  !=  'undefined')  {  
          this.keySet().push(key);    
          this.entrySet().push(entry);    
      } 
 } 

  // return entry by the gaven key    value 
   SimpleMap.prototype.get  =   function (key)  {  
       var  index  =   this.indexOf(key);
        if (index  !=   - 1 )  {
           return   this.entrySet()[index];
      } 
       return   null ;         
 }  
  // return the size of the map 
   SimpleMap.prototype.size  =   function ()  {    
      return   this.keySet().length;
 }   
  // clear all    mapping records in the map 
   SimpleMap.prototype.clear  =   function ()  {    
       while ( this.keySet().length  >   0 )  { 
          this.keySet().pop();
          this.entrySet().pop();
     } 
 }   
  // return the index of the key in the map's keySet Array if unfind return -1 
   SimpleMap.prototype.indexOf  =   function (key)  { 
       if (key  !=   null   &&  key  !=  'undefined')  { 
           for ( var  i = 0 ;i < this.keySet().length;i ++ )  {    
               if ( this.keySet()[i]  ==  key)  {
                  return  i;
             } 
         }     
     }                    
      return   - 1 ;
 }  
  // return a mapping record from the map by the gaven key value 
   SimpleMap.prototype.remove  =   function (key)  {
      var  index  =   this.indexOf(key);
       if (index  !=   - 1 )  { 
          var  tempKey  =   new  Array(); 
          var  tempEntry  =   new  Array(); 
           for ( var  i = this.keySet().length;i > 0 ;i -- )  {    
               if (i  !=  (index + 1 ))  {     
                 tempKey.push( this.keySet().pop());
                 tempEntry.push( this.entrySet().pop());
              } else  {    
                  this.keySet().pop();
                  this.entrySet().pop();
             } 
         }            
           for ( var  i = tempKey.length;i > 0 ;i -- )  {    
              this.keySet().push(tempKey.pop());
              this.entrySet().push(tempEntry.pop()); 
         }           
     }  
	 
}   
