Adds some missing methods to TreeSet, which really ought to be an instance of Collection

This commit is contained in:
Eric Scharff 2007-10-16 12:14:03 -06:00
parent 0a5de853d3
commit 6be84b4653

View File

@ -1,6 +1,6 @@
package java.util;
public class TreeSet<T> implements Iterable<T> {
public class TreeSet<T> implements Collection<T> {
private PersistentSet<Cell<T>> set;
private int size;
@ -59,6 +59,15 @@ public class TreeSet<T> implements Iterable<T> {
return size;
}
public boolean contains(T value) {
return !set.find(new Cell(value, null)).fresh();
}
public void clear() {
set = new PersistentSet(set.comparator());
size = 0;
}
private class MyIterator<T> implements java.util.Iterator<T> {
private PersistentSet.Path<Cell<T>> path;
private PersistentSet.Path<Cell<T>> nextPath;