diff --git a/classpath/java/util/Collections.java b/classpath/java/util/Collections.java index d4b295fd58..250b7bbe97 100644 --- a/classpath/java/util/Collections.java +++ b/classpath/java/util/Collections.java @@ -45,6 +45,10 @@ public class Collections { synchronized (lock) { return collection.size(); } } + public boolean isEmpty() { + return size() == 0; + } + public synchronized boolean contains(T e) { synchronized (lock) { return collection.contains(e); } } @@ -77,7 +81,6 @@ public class Collections { public void addAll(Collection c) { synchronized (lock) { ((Set)collection).addAll(c); } } - } static class SynchronizedIterator implements Iterator { diff --git a/classpath/java/util/HashMap.java b/classpath/java/util/HashMap.java index 8892699358..91daef790c 100644 --- a/classpath/java/util/HashMap.java +++ b/classpath/java/util/HashMap.java @@ -293,6 +293,10 @@ public class HashMap implements Map { return HashMap.this.size(); } + public boolean isEmpty() { + return HashMap.this.isEmpty(); + } + public void addAll(Collection> c) { throw new UnsupportedOperationException(); } @@ -323,6 +327,10 @@ public class HashMap implements Map { return HashMap.this.size(); } + public boolean isEmpty() { + return HashMap.this.isEmpty(); + } + public boolean contains(K key) { return containsKey(key); } @@ -354,6 +362,10 @@ public class HashMap implements Map { return HashMap.this.size(); } + public boolean isEmpty() { + return HashMap.this.isEmpty(); + } + public boolean contains(V value) { return containsValue(value); } diff --git a/classpath/java/util/HashSet.java b/classpath/java/util/HashSet.java index a446e14dd2..48f6e1da63 100644 --- a/classpath/java/util/HashSet.java +++ b/classpath/java/util/HashSet.java @@ -22,6 +22,10 @@ public class HashSet implements Set { return map.size(); } + public boolean isEmpty() { + return map.isEmpty(); + } + public boolean contains(T element) { return map.containsKey(element); } diff --git a/classpath/java/util/TreeSet.java b/classpath/java/util/TreeSet.java index dbebe04fbc..7f4eb64206 100644 --- a/classpath/java/util/TreeSet.java +++ b/classpath/java/util/TreeSet.java @@ -63,6 +63,10 @@ public class TreeSet implements Collection { return size; } + public boolean isEmpty() { + return size == 0; + } + public boolean contains(T value) { return !set.find(new Cell(value, null)).fresh(); }