From 6be84b4653a677abe3446249e11f66dda372f6a7 Mon Sep 17 00:00:00 2001 From: Eric Scharff Date: Tue, 16 Oct 2007 12:14:03 -0600 Subject: [PATCH] Adds some missing methods to TreeSet, which really ought to be an instance of Collection --- classpath/java/util/TreeSet.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/classpath/java/util/TreeSet.java b/classpath/java/util/TreeSet.java index a35fe754ff..47343c65d3 100644 --- a/classpath/java/util/TreeSet.java +++ b/classpath/java/util/TreeSet.java @@ -1,6 +1,6 @@ package java.util; -public class TreeSet implements Iterable { +public class TreeSet implements Collection { private PersistentSet> set; private int size; @@ -59,6 +59,15 @@ public class TreeSet implements Iterable { 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 implements java.util.Iterator { private PersistentSet.Path> path; private PersistentSet.Path> nextPath;