/*
  javascript.util is a port of selected parts of java.util to JavaScript which
  main purpose is to ease porting Java code to JavaScript.

  Copyright (C) 2011 by Björn Harrtell

  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  THE SOFTWARE.
*/
(function() {var c=null;function d(){return function(){}}function f(a,b){var e=a.split("."),h=window;!(e[0]in h)&&h.execScript&&h.execScript("var "+e[0]);for(var q;e.length&&(q=e.shift());)!e.length&&b!==void 0?h[q]=b:h=h[q]?h[q]:h[q]={}}f("javascript.util.version","0.7.0");function g(a){this.message=a||""}f("javascript.util.OperationNotSupported",g);g.prototype=Error();g.prototype.name="OperationNotSupported";g.prototype.name=g.prototype.name;function i(a){this.message=a||""}
f("javascript.util.IndexOutOfBoundsException",i);i.prototype=Error();i.prototype.name="IndexOutOfBoundsException";i.prototype.name=i.prototype.name;function j(a){this.message=a||""}f("javascript.util.NoSuchElementException",j);j.prototype=Error();j.prototype.name="NoSuchElementException";j.prototype.name=j.prototype.name;function k(a){this.message=a||""}f("javascript.util.EmptyStackException",k);k.prototype=Error();k.prototype.name="EmptyStackException";k.prototype.name=k.prototype.name;
function l(){}f("javascript.util.Iterator",l);l.prototype.d=d();l.prototype.hasNext=l.prototype.d;l.prototype.next=d();l.prototype.next=l.prototype.next;l.prototype.remove=d();l.prototype.remove=l.prototype.remove;function m(){}f("javascript.util.Collection",m);m.prototype.add=d();m.prototype.add=m.prototype.add;m.prototype.f=d();m.prototype.isEmpty=m.prototype.f;m.prototype.e=d();m.prototype.iterator=m.prototype.e;m.prototype.size=d();m.prototype.size=m.prototype.size;m.prototype.b=d();
m.prototype.toArray=m.prototype.b;function n(){}f("javascript.util.List",n);n.prototype=new m;n.prototype.get=d();n.prototype.get=n.prototype.get;n.prototype.g=d();n.prototype.addAll=n.prototype.g;function o(a){this.a=[];a instanceof m&&this.g(a)}f("javascript.util.ArrayList",o);o.prototype=new n;o.prototype.a=c;o.prototype.add=function(a){this.a.push(a);return!0};o.prototype.add=o.prototype.add;o.prototype.g=function(a){for(a=a.e();a.d();)this.add(a.next());return!0};o.prototype.addAll=o.prototype.g;
o.prototype.e=function(){return new p(this)};o.prototype.iterator=o.prototype.e;o.prototype.get=function(a){if(a<0||a>=this.size())throw new i;return this.a[a]};o.prototype.get=o.prototype.get;o.prototype.f=function(){return this.a.length===0};o.prototype.isEmpty=o.prototype.f;o.prototype.size=function(){return this.a.length};o.prototype.size=o.prototype.size;o.prototype.b=function(){for(var a=[],b=0;b<this.a.length;b++)a.push(this.a[b]);return a};o.prototype.toArray=o.prototype.b;
function p(a){this.h=a}o.Iterator=p;p.prototype.h=c;p.prototype.position=0;p.prototype.next=function(){if(this.position===this.h.size())throw new j;return this.h.get(this.position++)};p.prototype.next=p.prototype.next;p.prototype.d=function(){return this.position<this.h.size()?!0:!1};p.prototype.hasNext=p.prototype.d;p.prototype.remove=function(){throw new g;};p.prototype.remove=p.prototype.remove;function r(){}f("javascript.util.Map",r);r.prototype.get=d();r.prototype.get=r.prototype.get;
r.prototype.put=d();r.prototype.put=r.prototype.put;r.prototype.size=d();r.prototype.size=r.prototype.size;r.prototype.c=d();r.prototype.values=r.prototype.c;function s(){}f("javascript.util.Arrays",s);
s.sort=function(){var a=arguments[0],b,e;if(arguments.length===1)a.sort();else if(arguments.length===2)e=arguments[1],a.sort(function(a,b){return e.compare(a,b)});else if(arguments.length===3){b=a.slice(arguments[1],arguments[2]);b.sort();var h=a.slice(0,arguments[1]).concat(b,a.slice(arguments[2],a.length));a.splice(0,a.length);for(b=0;b<h.length;b++)a.push(h[b])}else if(arguments.length===4){b=a.slice(arguments[1],arguments[2]);e=arguments[3];b.sort(function(a,b){return e.compare(a,b)});h=a.slice(0,
arguments[1]).concat(b,a.slice(arguments[2],a.length));a.splice(0,a.length);for(b=0;b<h.length;b++)a.push(h[b])}};s.asList=function(a){for(var b=new o,e=0;e<a.length;e++)b.add(a[e]);return b};f("javascript.util.SortedMap",d());function t(){this.object={}}f("javascript.util.HashMap",t);t.prototype.object=c;t.prototype.get=function(a){return this.object[a]||c};t.prototype.get=t.prototype.get;t.prototype.put=function(a,b){return this.object[a]=b};t.prototype.put=t.prototype.put;
t.prototype.c=function(){var a=new o,b;for(b in this.object)this.object.hasOwnProperty(b)&&a.add(this.object[b]);return a};t.prototype.values=t.prototype.c;t.prototype.size=function(){return this.c().size()};t.prototype.size=t.prototype.size;function u(){}f("javascript.util.Set",u);u.prototype.contains=d();u.prototype.contains=u.prototype.contains;f("javascript.util.SortedSet",d());function v(){this.a=[]}f("javascript.util.TreeSet",v);v.prototype.a=c;
v.prototype.contains=function(a){for(var b=0;b<this.a.length;b++)if(this.a[b].compareTo(a)===0)return!0;return!1};v.prototype.contains=v.prototype.contains;v.prototype.add=function(a){if(this.contains(a))return!1;for(var b=0;b<this.a.length;b++)if(this.a[b].compareTo(a)===1)return this.a.splice(b,0,a),!0;this.a.push(a);return!0};v.prototype.add=v.prototype.add;v.prototype.size=function(){return this.a.length};v.prototype.size=v.prototype.size;v.prototype.f=function(){return this.a.length===0};
v.prototype.isEmpty=v.prototype.f;v.prototype.b=function(){for(var a=[],b=0;b<this.a.length;b++)a.push(this.a[b]);return a};v.prototype.toArray=v.prototype.b;v.prototype.e=function(){return new w(this)};v.prototype.iterator=v.prototype.e;function w(a){this.i=a}v.Iterator=w;w.prototype.i=c;w.prototype.position=0;w.prototype.next=function(){if(this.position===this.i.size())throw new j;return this.i.a[this.position++]};w.prototype.next=w.prototype.next;
w.prototype.d=function(){return this.position<this.i.size()?!0:!1};w.prototype.hasNext=w.prototype.d;w.prototype.remove=function(){throw new g;};w.prototype.remove=w.prototype.remove;function x(){this.a=[]}f("javascript.util.Stack",x);x.prototype=new n;x.prototype.a=c;x.prototype.push=function(a){this.a.push(a);return a};x.prototype.push=x.prototype.push;x.prototype.pop=function(){if(this.a.length===0)throw new k;return this.a.pop()};x.prototype.pop=x.prototype.pop;
x.prototype.j=function(){if(this.a.length===0)throw new k;return this.a[this.a.length-1]};x.prototype.peek=x.prototype.j;x.prototype.empty=function(){return this.a.length===0?!0:!1};x.prototype.empty=x.prototype.empty;x.prototype.search=function(a){return this.a.indexOf(a)};x.prototype.search=x.prototype.search;x.prototype.size=function(){return this.a.length};x.prototype.size=x.prototype.size;x.prototype.b=function(){for(var a=[],b=0;b<this.a.length;b++)a.push(this.a[b]);return a};
x.prototype.toArray=x.prototype.b;function y(){this.a=[]}f("javascript.util.TreeMap",y);y.prototype.a=c;y.prototype.get=function(a){for(var b=0;b<this.a.length;b++){var e=this.a[b];if(e.key.compareTo(a)===0)return e.value}return c};y.prototype.get=y.prototype.get;y.prototype.put=function(a,b){var e=this.get(a);if(e){var h=e.value;e.value=b;return h}for(var h={key:a,value:b},q=0;q<this.a.length;q++)if(e=this.a[q],e.key.compareTo(a)===1)return this.a.splice(q,0,h),c;this.a.push({key:a,value:b});return c};
y.prototype.put=y.prototype.put;y.prototype.c=function(){for(var a=new o,b=0;b<this.a.length;b++)a.add(this.a[b].value);return a};y.prototype.values=y.prototype.c;y.prototype.size=function(){return this.c().size()};y.prototype.size=y.prototype.size;})();
