////////////////////////////////////////////////////////////////////
// Hashtable class
Hashtable.CLASS_NAME = "Hashtable";
Hashtable.prototype.hash = null;
Hashtable.prototype.keys = null;

// Constructor
function Hashtable() {
  this.hash = new Array();
  this.keys = new Array();
}

/////////////////////////////////////////////////////////////////////////////////////
// Static functions
/////////////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////////////
// Instance functions
/////////////////////////////////////////////////////////////////////////////////////

Hashtable.prototype.clear = function() {
  this.hash = new Array();
  this.keys = new Array();
}

Hashtable.prototype.containsKey = function(key) {
  return (this.hash[key]?true:false);
}

Hashtable.prototype.get = function(key) {
  return this.hash[key];
}

Hashtable.prototype.put = function(key, value) {
  if (value == null) {
    return null;
  }
  if (this.hash[key] == null) {
    this.keys[this.keys.length] = key;
  }
  this.hash[key] = value;
}

Hashtable.prototype.remove = function(key) {
  var obj = this.hash[key];
  this.hash[key] = null;
  return obj;
}

Hashtable.prototype.size = function() {
  var size = 0;
  for (var i in this.hash) {
    if (this.hash[i] != null) {
      size++;
    }
  }
  return size;
}


