|
@@ -9,6 +9,8 @@ import java.util.TreeSet;
|
9
|
9
|
*/
|
10
|
10
|
public class ComparableTreeSet<_> extends TreeSet implements Comparable {
|
11
|
11
|
|
|
12
|
+ TreeSet thisTree = this;
|
|
13
|
+
|
12
|
14
|
public ComparableTreeSet(_... arr) {
|
13
|
15
|
addAll(Arrays.asList(arr));
|
14
|
16
|
}
|
|
@@ -17,15 +19,18 @@ public class ComparableTreeSet<_> extends TreeSet implements Comparable {
|
17
|
19
|
|
18
|
20
|
}
|
19
|
21
|
|
20
|
|
- public Integer compareTo(ComparableTreeSet<_> o) {
|
21
|
|
- if(this.first().equals(o.first())){
|
22
|
|
- return 0;
|
23
|
|
- }
|
24
|
|
- return -1;
|
|
22
|
+ public int compareTo(ComparableTreeSet<_> o) {
|
|
23
|
+ return thisTree.first().toString().compareTo(o.first().toString());
|
25
|
24
|
}
|
26
|
25
|
|
27
|
26
|
public String toString(){
|
28
|
|
- return null;
|
|
27
|
+ String output = "[";
|
|
28
|
+ for(Object i : thisTree){
|
|
29
|
+ output = output + i + ", ";
|
|
30
|
+ }
|
|
31
|
+
|
|
32
|
+ output = output.substring(0, output.length() - 2) + "]";
|
|
33
|
+ return output;
|
29
|
34
|
}
|
30
|
35
|
|
31
|
36
|
@Override
|