mirror of
https://github.com/corda/corda.git
synced 2025-01-19 11:16:54 +00:00
add TreeSet(Collection) constructor
This commit is contained in:
parent
0ca7ed8c67
commit
3aff7dc861
@ -33,6 +33,14 @@ public class TreeSet<T> extends AbstractSet<T> implements Collection<T> {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public TreeSet(Collection<? extends T> collection) {
|
||||
this();
|
||||
|
||||
for (T item: collection) {
|
||||
add(item);
|
||||
}
|
||||
}
|
||||
|
||||
public Iterator<T> iterator() {
|
||||
return new MyIterator<T>(set.first());
|
||||
|
@ -1,6 +1,8 @@
|
||||
import java.util.Comparator;
|
||||
import java.util.TreeSet;
|
||||
import java.util.TreeMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Iterator;
|
||||
|
||||
@ -87,5 +89,13 @@ public class Tree {
|
||||
map.put("y", "Y");
|
||||
|
||||
isEqual(printMap(map), "a=A, b=B, c=C, q=Q, y=Y, z=Z");
|
||||
|
||||
Collection<Integer> list = new ArrayList<Integer>();
|
||||
list.add(7);
|
||||
list.add(2);
|
||||
list.add(9);
|
||||
list.add(2);
|
||||
|
||||
isEqual(printList(new TreeSet<Integer>(list)), "2, 7, 9");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user