/**
 * Hashtable
 * @author Michael Synovic
 * @see http://work.synovic.net/hashtable/hashtable.html 
 * @fileoverview This is a Javascript implementation of the Java Hashtable object.
 */
function Hashtable(){
  this.n=[];
}
/**
 * @return void
 */
Hashtable.prototype.clear=function(){
  this.n=[];
}
/**
 * @return void
 */
Hashtable.prototype.empty=function(){
  this.clear();
}
/**
 * @return whether the key is in the hashtable
 * @type boolean
 */
Hashtable.prototype.containsKey=function(key){
  var ai=false;
  for(var i in this.n){
    if(i==key&&null!=this.n[i]) {
      ai=true;
      break;
    }
  }
  return ai;
}
/**
 * @return whether the value is in the hashtable
 * @type boolean
 */
Hashtable.prototype.containsValue=function(pV){
  var ap=false;
  if(null!=pV)
  for(var i in this.n){
    if(this.n[i]==pV) {
      ap=true;
      break;
    }
  }
  return ap;
}
/**
 * @return the object in the hashtable by key
 * @type object
 */
Hashtable.prototype.get=function(pK){
  return this.n[pK];
}
/**
 * @return whether the hash / array is empty
 * @type int
 */
Hashtable.prototype.isEmpty=function(){
  return(parseInt(this.size())==0)
}
/**
 * @return returns an array of the keys in this hashtable
 * @type array
 */ 
Hashtable.prototype.keys=function(){
  var keys=[];
  for(var i in this.n){
    if(null!=this.n[i]){
      keys.push(i);
    }
  }
  return keys;
}
/**
 * @return add object by key
 * @type void
 */ 
Hashtable.prototype.put=function(pK,pV){
  if(null==pK || null==pV) {
    throw new Error("NullPointerException: {"+key+"},{"+value+"}");
  }
  else {
    this.n[pK]=pV;
  }
}
/**
 * @return pop the object by key and return it
 * @type object
 */ 
Hashtable.prototype.remove=function(pK){
  var bh=this.n[pK];
  this.n[pK]=null;
  return bh;
}
/**
 * @return get the size of the array
 * @type int
 */ 
Hashtable.prototype.size=function(){
  var s=0;
  for(var i in this.n){
    if(null!=this.n[i]) {
        s++;
    }
  }
  return s;
}
/**
 * @return flatten the array into a string
 * @type string
 */ 
Hashtable.prototype.toString=function(){
  var s="";
  for(var i in this.n){
    if(null!=this.n[i]) {
        s+="{"+i+"},{"+this.n[i]+"}\n";
    }
  }
  return s;
}
/**
 * @return an array of all values in the hash
 * @type array
 */ 
Hashtable.prototype.values=function(){
  var v=[];
  for(var i in this.n){
    if(null!=this.n[i]) {
        v.push(this.n[i]);
    }
  }
  return v;
}