diff --git a/classpath/java/util/TreeSet.java b/classpath/java/util/TreeSet.java index 0faac7ad12..1768d64843 100644 --- a/classpath/java/util/TreeSet.java +++ b/classpath/java/util/TreeSet.java @@ -15,7 +15,6 @@ import avian.Cell; public class TreeSet extends AbstractSet implements Collection { private PersistentSet> set; - private int size; public TreeSet(final Comparator comparator) { set = new PersistentSet(new Comparator>() { @@ -23,7 +22,6 @@ public class TreeSet extends AbstractSet implements Collection { return comparator.compare(a.value, b.value); } }); - size = 0; } public TreeSet() { @@ -66,7 +64,6 @@ public class TreeSet extends AbstractSet implements Collection { PersistentSet.Path> p = set.find(new Cell(value, null)); if (p.fresh()) { set = p.add(); - ++size; return true; } return false; @@ -76,7 +73,6 @@ public class TreeSet extends AbstractSet implements Collection { PersistentSet.Path> p = set.find(new Cell(value, null)); if (p.fresh()) { set = p.add(); - ++size; return null; } else { T old = p.value().value; @@ -100,8 +96,6 @@ public class TreeSet extends AbstractSet implements Collection { if (p.fresh()) { return null; } else { - --size; - Cell old = p.value(); if (p.value().next != null) { @@ -119,11 +113,11 @@ public class TreeSet extends AbstractSet implements Collection { } public int size() { - return size; + return set.size(); } public boolean isEmpty() { - return size == 0; + return set.size() != 0; } public boolean contains(Object value) { @@ -132,7 +126,6 @@ public class TreeSet extends AbstractSet implements Collection { public void clear() { set = new PersistentSet(set.comparator()); - size = 0; } private class MyIterator implements java.util.Iterator { @@ -180,8 +173,6 @@ public class TreeSet extends AbstractSet implements Collection { public void remove() { if (! canRemove) throw new IllegalStateException(); - --size; - if (prevPrevCell != null && prevPrevCell.next == prevCell) { // cell to remove is not the first in the list. prevPrevCell.next = prevCell.next;