implement TreeSet.toString()

This commit is contained in:
Joel Dice 2007-10-16 19:17:37 -06:00
parent 3779f21424
commit f84b865f03
2 changed files with 6 additions and 2 deletions

View File

@ -3,10 +3,10 @@ package java.util;
public class Collections {
private Collections() { }
static String toString(List l) {
static String toString(Collection c) {
StringBuilder sb = new StringBuilder();
sb.append("[");
for (Iterator it = l.iterator(); it.hasNext();) {
for (Iterator it = c.iterator(); it.hasNext();) {
sb.append(it.next());
if (it.hasNext()) {
sb.append(",");

View File

@ -17,6 +17,10 @@ public class TreeSet<T> implements Collection<T> {
return new MyIterator<T>(set.first());
}
public String toString() {
return Collections.toString(this);
}
public boolean add(T value) {
PersistentSet.Path<Cell<T>> p = set.find(new Cell(value, null));
if (p.fresh()) {