Added methods isEmpty(), putAll(), toArray() to interfaces List and Map

This commit is contained in:
Eric Scharff
2007-09-26 08:57:34 -06:00
parent 4ae4221701
commit b02b98609e
10 changed files with 115 additions and 1 deletions

View File

@ -44,6 +44,10 @@ public class HashMap<K, V> implements Map<K, V> {
return r;
}
public boolean isEmpty() {
return size() == 0;
}
public int size() {
return size;
}
@ -179,6 +183,12 @@ public class HashMap<K, V> implements Map<K, V> {
return (c == null ? null : c.getValue());
}
public void putAll(Map<? extends K,? extends V> elts) {
for (Map.Entry<? extends K, ? extends V> entry : elts.entrySet()) {
put(entry.getKey(), entry.getValue());
}
}
public V remove(K key) {
Cell<K, V> c = removeCell(key);
return (c == null ? null : c.getValue());