Fixed bugs to Dictionary Classes
This commit is contained in:
@@ -122,6 +122,22 @@ public class ChainingHashTable<K,V> implements Dictionary<K,V> {
|
||||
}
|
||||
}
|
||||
|
||||
protected Entry<K, V> insert_refactor(Entry<K,V> in_e) throws InvalidKeyException {
|
||||
// in_e not checked because used internally
|
||||
int h = hash(in_e.getKey());
|
||||
if (table.get(h) == AVAIBLE) {
|
||||
LogFile<K, V> n = new LogFile<K, V>();
|
||||
table.set(h,n);
|
||||
avaible_slots--;
|
||||
elements++;
|
||||
return n.insert(in_e);
|
||||
} else {
|
||||
LogFile<K, V> n = table.get(h);
|
||||
elements++;
|
||||
return n.insert(in_e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entry<K, V> remove(Entry<K, V> e) throws InvalidEntryException {
|
||||
if (e == null)
|
||||
@@ -180,7 +196,7 @@ public class ChainingHashTable<K,V> implements Dictionary<K,V> {
|
||||
table = table2;
|
||||
|
||||
for (Entry<K,V> e : ite){
|
||||
insert(e.getKey(),e.getValue());
|
||||
insert_refactor(e);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user