JAL-1807 update
[jalviewjs.git] / site / j2s / java / util / TreeSet.js
1 Clazz.load(["java.util.AbstractSet","$.SortedSet","$.TreeMap"],"java.util.TreeSet",["java.lang.IllegalArgumentException"],function(){
2 c$=Clazz.decorateAsClass(function(){
3 this.backingMap=null;
4 Clazz.instantialize(this,arguments);
5 },java.util,"TreeSet",java.util.AbstractSet,[java.util.SortedSet,Cloneable,java.io.Serializable]);
6 Clazz.makeConstructor(c$,
7 ($fz=function(map){
8 Clazz.superConstructor(this,java.util.TreeSet,[]);
9 this.backingMap=map;
10 },$fz.isPrivate=true,$fz),"java.util.SortedMap");
11 Clazz.makeConstructor(c$,
12 function(){
13 Clazz.superConstructor(this,java.util.TreeSet,[]);
14 this.backingMap=new java.util.TreeMap();
15 });
16 Clazz.makeConstructor(c$,
17 function(collection){
18 this.construct();
19 this.addAll(collection);
20 },"java.util.Collection");
21 Clazz.makeConstructor(c$,
22 function(comparator){
23 Clazz.superConstructor(this,java.util.TreeSet,[]);
24 this.backingMap=new java.util.TreeMap(comparator);
25 },"java.util.Comparator");
26 Clazz.makeConstructor(c$,
27 function(set){
28 this.construct(set.comparator());
29 var it=set.iterator();
30 while(it.hasNext()){
31 this.add(it.next());
32 }
33 },"java.util.SortedSet");
34 Clazz.overrideMethod(c$,"add",
35 function(object){
36 return this.backingMap.put(object,object)==null;
37 },"~O");
38 Clazz.overrideMethod(c$,"clear",
39 function(){
40 this.backingMap.clear();
41 });
42 Clazz.defineMethod(c$,"clone",
43 function(){
44 try{
45 var clone=Clazz.superCall(this,java.util.TreeSet,"clone",[]);
46 if(Clazz.instanceOf(this.backingMap,java.util.TreeMap)){
47 clone.backingMap=(this.backingMap).clone();
48 }else{
49 clone.backingMap=new java.util.TreeMap(this.backingMap);
50 }return clone;
51 }catch(e){
52 if(Clazz.instanceOf(e,CloneNotSupportedException)){
53 return null;
54 }else{
55 throw e;
56 }
57 }
58 });
59 Clazz.defineMethod(c$,"comparator",
60 function(){
61 return this.backingMap.comparator();
62 });
63 Clazz.overrideMethod(c$,"contains",
64 function(object){
65 return this.backingMap.containsKey(object);
66 },"~O");
67 Clazz.overrideMethod(c$,"first",
68 function(){
69 return this.backingMap.firstKey();
70 });
71 Clazz.overrideMethod(c$,"headSet",
72 function(end){
73 var c=this.backingMap.comparator();
74 if(c==null){
75 (end).compareTo(end);
76 }else{
77 c.compare(end,end);
78 }return new java.util.TreeSet(this.backingMap.headMap(end));
79 },"~O");
80 Clazz.overrideMethod(c$,"isEmpty",
81 function(){
82 return this.backingMap.isEmpty();
83 });
84 Clazz.defineMethod(c$,"iterator",
85 function(){
86 return this.backingMap.keySet().iterator();
87 });
88 Clazz.overrideMethod(c$,"last",
89 function(){
90 return this.backingMap.lastKey();
91 });
92 Clazz.overrideMethod(c$,"remove",
93 function(object){
94 return this.backingMap.remove(object)!=null;
95 },"~O");
96 Clazz.overrideMethod(c$,"size",
97 function(){
98 return this.backingMap.size();
99 });
100 Clazz.overrideMethod(c$,"subSet",
101 function(start,end){
102 var c=this.backingMap.comparator();
103 if(c==null){
104 if((start).compareTo(end)<=0){
105 return new java.util.TreeSet(this.backingMap.subMap(start,end));
106 }}else{
107 if(c.compare(start,end)<=0){
108 return new java.util.TreeSet(this.backingMap.subMap(start,end));
109 }}throw new IllegalArgumentException();
110 },"~O,~O");
111 Clazz.overrideMethod(c$,"tailSet",
112 function(start){
113 var c=this.backingMap.comparator();
114 if(c==null){
115 (start).compareTo(start);
116 }else{
117 c.compare(start,start);
118 }return new java.util.TreeSet(this.backingMap.tailMap(start));
119 },"~O");
120 });