]> source.dussan.org Git - jgit.git/commitdiff
ObjectIdSubclassMap: Add isEmpty() method 68/568/1
authorShawn O. Pearce <spearce@spearce.org>
Fri, 16 Apr 2010 15:41:59 +0000 (08:41 -0700)
committerShawn O. Pearce <spearce@spearce.org>
Fri, 16 Apr 2010 23:30:21 +0000 (16:30 -0700)
This class behaves like a cross between a Set and a Map, sometimes
we might expect to use the method isEmpty() to test for size() == 0.
So implement it, reducing the surprise folks get when they are given
one of these objects.

Change-Id: I0d68e1243da8e62edf79c6ba4fd925f643e80a88
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectIdSubclassMap.java

index a0b6d0ed24af9b0d67cdd14b9e3736cb52132939..aa4bf99f3308c0699adb7012a4ee36b4ff2092d5 100644 (file)
@@ -135,6 +135,11 @@ public class ObjectIdSubclassMap<V extends ObjectId> implements Iterable<V> {
                return size;
        }
 
+       /** @return true if {@link #size()} is 0. */
+       public boolean isEmpty() {
+               return size == 0;
+       }
+
        public Iterator<V> iterator() {
                return new Iterator<V>() {
                        private int found;