/**
* used like java.lang.hashmap
*/
function testhashmap(){
alert("hashmap test begin:");
try{
}
catch(e){
alert(e);
}
alert("hashmap test end");
}
function hashmap()
{
private:
this.len=8;
this.table=new array();
this.length=0;
this.hash=hash;
function hash(x){
var h = x.hashcode();
h += ~(h << 9);
h ^= (h >>> 14);
h += (h << 4);
h ^= (h >>> 10);
return h;
}
this.rehash=rehash;
function rehash() {
var oldtable = this.table;
this.table=new array();
//transfer
for (var i = 0; i< oldtable.length; i++) {
var e = oldtable[i];
if (e != null) {
oldtable[i] = null;
do {
var next = e.next;
var j = this.indexfor(e.hash);
e.next = this.table[j];
this.table[j] = e;
e = next;
} while (e != null);
}
}
//alert("rehash to :"+this.len);
}
this.indexfor=indexfor;
function indexfor(h) {
var index= h & (this.len-1);
return index;
}
function entry(h,k,v,n){
this.value = v;
this.next = n;
this.key = k;
this.hash = h;