Object remove(Object key) {
int bin=key.hashCode()%table.length;
HashEntry ptr=table[bin];
- if (ptr.key==key) {
+ if (ptr.key.equals(key)) {
table[bin]=ptr.next;
numItems--;
return ptr.value;
}
while(ptr.next!=null) {
- if (ptr.next.key==key) {
+ if (ptr.next.key.equals(key)) {
Object oldvalue=ptr.value;
ptr.next=ptr.next.next;
numItems--;
int bin=key.hashCode()%table.length;
HashEntry ptr=table[bin];
while(ptr!=null) {
- if (ptr.key==key) {
+ if (ptr.key.equals(key)) {
return ptr.value;
}
}
int bin=key.hashCode()%table.length;
HashEntry ptr=table[bin];
while(ptr!=null) {
- if (ptr.key==key) {
+ if (ptr.key.equals(key)) {
return true;
}
}
int bin=key.hashCode()%table.length;
HashEntry ptr=table[bin];
while(ptr!=null) {
- if (ptr.key==key) {
+ if (ptr.key.equals(key)) {
Object oldvalue=ptr.value;
ptr.value=value;
return oldvalue;