-public class HashMap{
+public class HashMap {
HashEntry[] table;
float loadFactor;
int numItems;
this.numItems=0;
this.threshold=(int)(loadFactor*table.length);
}
-
+
private static int computeCapacity(int capacity) {
- int x=16;
- while(x<capacity)
- x=x<<1;
- return x;
+ int x=16;
+ while(x<capacity)
+ x=x<<1;
+ return x;
}
private static int hash(Object o, int length) {
- int orig=o.hashCode();
- orig=orig^(orig>>>22)^(orig>>>10);
- orig=orig^(orig>>>8)^(orig>>4);
- return orig&(length-1);
+ int orig=o.hashCode();
+ orig=orig^(orig>>>22)^(orig>>>10);
+ orig=orig^(orig>>>8)^(orig>>4);
+ return orig&(length-1);
}
void resize() {
}
}
- public void clear() {
- for(int i=0;i<table.length;i++)
- table[i]=null;
- numItems=0;
- }
+ public void clear() {
+ for(int i=0; i<table.length; i++)
+ table[i]=null;
+ numItems=0;
+ }
public boolean isEmpty() {
return numItems==0;