function sphash() {
  // actual map
  this.map = {};
  
  // length
  this.length = 0;
}

sphash.prototype.exist = function(key) {
  return typeof this.map[key] != "undefined";
}

sphash.prototype.set = function(key, val) {
  if(!this.exist(key)){
    this.length++;
  }
  this.map[key] = val;
}

sphash.prototype.get = function(key) {
  if(this.exist(key)) {
    return this.map[key];
  }
  return null;
}

sphash.prototype.remove = function(key) {
  if(this.exist(key)) {
    this.length--;
    delete this.map[key];
  }
}

sphash.prototype.clear = function() {
  this.map = {};
  this.length = 0;
}

sphash.prototype.size = function() {
  return this.length;
}

sphash.prototype.keys = function() {
  var keys = new Array();
  for(var key in this.map){
    keys.push(key);
  }

  return keys;
}

sphash.prototype.dump = function() {
  var txt = "";
  for(var key in this.map){
    txt = txt + " [" + key + "]=" + this.map[key];
  }
  return txt;
}
