| Line 28... |
Line 28... |
| 28 |
if (entry==NIL) continue;
|
28 |
if (entry==NIL) continue;
|
| 29 |
if (entry.key.equals(key)) return entry.value; // success
|
29 |
if (entry.key.equals(key)) return entry.value; // success
|
| 30 |
}
|
30 |
}
|
| 31 |
return null; // failure: key not found
|
31 |
return null; // failure: key not found
|
| 32 |
}
|
32 |
}
|
| 33 |
|
33 |
|
| 34 |
//added these to get the interface to behave
|
- |
|
| 35 |
public Set keySet() { System.out.println("DO NOT USE keySet()!"); return null; }
|
- |
|
| 36 |
public Set entrySet() { System.out.println("DO NOT USE entrySet()!"); return null; }
|
- |
|
| 37 |
public void putAll( Map t) { System.out.println("DO NOT USE putAll()!"); }
|
- |
|
| 38 |
public Collection values() { System.out.println("DO NOT USE values()!"); return null; }
|
- |
|
| 39 |
public boolean containsValue( Object value ) { System.out.println("DO NOT USE containsValue()!"); return false; }
|
- |
|
| 40 |
public boolean containsKey( Object key ) { System.out.println("DO NOT USE containsKey()!"); return false; }
|
- |
|
| 41 |
public boolean isEmpty() { System.out.println("DO NOT USE isEmpty()!"); return false; }
|
- |
|
| 42 |
public void clear() { System.out.println("DO NOT USE clear()!"); }
|
- |
|
| 43 |
|
- |
|
| 44 |
public Object put(Object key, Object value) {
|
34 |
public Object put(Object key, Object value) {
|
| 45 |
if (used>loadFactor*entries.length) rehash();
|
35 |
if (used>loadFactor*entries.length) rehash();
|
| 46 |
int h=hash(key);
|
36 |
int h=hash(key);
|
| 47 |
for (int i=0; i<entries.length; i++) {
|
37 |
for (int i=0; i<entries.length; i++) {
|
| 48 |
int j = nextProbe(h,i);
|
38 |
int j = nextProbe(h,i);
|