JAL-1807 still testing
[jalviewjs.git] / bin / javajs / util / BS.js
index 5677631..bc34911 100644 (file)
-Clazz.declarePackage ("javajs.util");
-Clazz.load (["javajs.api.JSONEncodable"], "javajs.util.BS", ["java.lang.IndexOutOfBoundsException", "$.NegativeArraySizeException", "javajs.util.PT", "$.SB"], function () {
-c$ = Clazz.decorateAsClass (function () {
-this.words = null;
-this.wordsInUse = 0;
-this.sizeIsSticky = false;
-Clazz.instantialize (this, arguments);
-}, javajs.util, "BS", null, [Cloneable, javajs.api.JSONEncodable]);
-c$.wordIndex = Clazz.defineMethod (c$, "wordIndex", 
-($fz = function (bitIndex) {
-return bitIndex >> 5;
-}, $fz.isPrivate = true, $fz), "~N");
-Clazz.defineMethod (c$, "recalculateWordsInUse", 
-($fz = function () {
-var i;
-for (i = this.wordsInUse - 1; i >= 0; i--) if (this.words[i] != 0) break;
-
-this.wordsInUse = i + 1;
-}, $fz.isPrivate = true, $fz));
-Clazz.makeConstructor (c$, 
-function () {
-this.initWords (32);
-this.sizeIsSticky = false;
-});
-c$.newN = Clazz.defineMethod (c$, "newN", 
-function (nbits) {
-var bs =  new javajs.util.BS ();
-bs.init (nbits);
-return bs;
-}, "~N");
-Clazz.defineMethod (c$, "init", 
-($fz = function (nbits) {
-if (nbits < 0) throw  new NegativeArraySizeException ("nbits < 0: " + nbits);
-this.initWords (nbits);
-this.sizeIsSticky = true;
-}, $fz.isPrivate = true, $fz), "~N");
-Clazz.defineMethod (c$, "initWords", 
-($fz = function (nbits) {
-this.words =  Clazz.newIntArray (javajs.util.BS.wordIndex (nbits - 1) + 1, 0);
-}, $fz.isPrivate = true, $fz), "~N");
-Clazz.defineMethod (c$, "ensureCapacity", 
-($fz = function (wordsRequired) {
-if (this.words.length < wordsRequired) {
-var request = Math.max (2 * this.words.length, wordsRequired);
-this.setLength (request);
-this.sizeIsSticky = false;
-}}, $fz.isPrivate = true, $fz), "~N");
-Clazz.defineMethod (c$, "expandTo", 
-($fz = function (wordIndex) {
-var wordsRequired = wordIndex + 1;
-if (this.wordsInUse < wordsRequired) {
-this.ensureCapacity (wordsRequired);
-this.wordsInUse = wordsRequired;
-}}, $fz.isPrivate = true, $fz), "~N");
-Clazz.defineMethod (c$, "set", 
-function (bitIndex) {
-if (bitIndex < 0) throw  new IndexOutOfBoundsException ("bitIndex < 0: " + bitIndex);
-var wordIndex = javajs.util.BS.wordIndex (bitIndex);
-this.expandTo (wordIndex);
-this.words[wordIndex] |= (1 << bitIndex);
-}, "~N");
-Clazz.defineMethod (c$, "setBitTo", 
-function (bitIndex, value) {
-if (value) this.set (bitIndex);
- else this.clear (bitIndex);
-}, "~N,~B");
-Clazz.defineMethod (c$, "setBits", 
-function (fromIndex, toIndex) {
-if (fromIndex == toIndex) return;
-var startWordIndex = javajs.util.BS.wordIndex (fromIndex);
-var endWordIndex = javajs.util.BS.wordIndex (toIndex - 1);
-this.expandTo (endWordIndex);
-var firstWordMask = -1 << fromIndex;
-var lastWordMask = -1 >>> -toIndex;
-if (startWordIndex == endWordIndex) {
-this.words[startWordIndex] |= (firstWordMask & lastWordMask);
-} else {
-this.words[startWordIndex] |= firstWordMask;
-for (var i = startWordIndex + 1; i < endWordIndex; i++) this.words[i] = -1;
-
-this.words[endWordIndex] |= lastWordMask;
-}}, "~N,~N");
-Clazz.defineMethod (c$, "clear", 
-function (bitIndex) {
-if (bitIndex < 0) throw  new IndexOutOfBoundsException ("bitIndex < 0: " + bitIndex);
-var wordIndex = javajs.util.BS.wordIndex (bitIndex);
-if (wordIndex >= this.wordsInUse) return;
-this.words[wordIndex] &= ~(1 << bitIndex);
-this.recalculateWordsInUse ();
-}, "~N");
-Clazz.defineMethod (c$, "clearBits", 
-function (fromIndex, toIndex) {
-if (fromIndex == toIndex) return;
-var startWordIndex = javajs.util.BS.wordIndex (fromIndex);
-if (startWordIndex >= this.wordsInUse) return;
-var endWordIndex = javajs.util.BS.wordIndex (toIndex - 1);
-if (endWordIndex >= this.wordsInUse) {
-toIndex = this.length ();
-endWordIndex = this.wordsInUse - 1;
-}var firstWordMask = -1 << fromIndex;
-var lastWordMask = -1 >>> -toIndex;
-if (startWordIndex == endWordIndex) {
-this.words[startWordIndex] &= ~(firstWordMask & lastWordMask);
-} else {
-this.words[startWordIndex] &= ~firstWordMask;
-for (var i = startWordIndex + 1; i < endWordIndex; i++) this.words[i] = 0;
-
-this.words[endWordIndex] &= ~lastWordMask;
-}this.recalculateWordsInUse ();
-}, "~N,~N");
-Clazz.defineMethod (c$, "clearAll", 
-function () {
-while (this.wordsInUse > 0) this.words[--this.wordsInUse] = 0;
-
-});
-Clazz.defineMethod (c$, "get", 
-function (bitIndex) {
-if (bitIndex < 0) throw  new IndexOutOfBoundsException ("bitIndex < 0: " + bitIndex);
-var wordIndex = javajs.util.BS.wordIndex (bitIndex);
-return (wordIndex < this.wordsInUse) && ((this.words[wordIndex] & (1 << bitIndex)) != 0);
-}, "~N");
-Clazz.defineMethod (c$, "nextSetBit", 
-function (fromIndex) {
-if (fromIndex < 0) throw  new IndexOutOfBoundsException ("fromIndex < 0: " + fromIndex);
-var u = javajs.util.BS.wordIndex (fromIndex);
-if (u >= this.wordsInUse) return -1;
-var word = this.words[u] & (-1 << fromIndex);
-while (true) {
-if (word != 0) return (u * 32) + Integer.numberOfTrailingZeros (word);
-if (++u == this.wordsInUse) return -1;
-word = this.words[u];
-}
-}, "~N");
-Clazz.defineMethod (c$, "nextClearBit", 
-function (fromIndex) {
-if (fromIndex < 0) throw  new IndexOutOfBoundsException ("fromIndex < 0: " + fromIndex);
-var u = javajs.util.BS.wordIndex (fromIndex);
-if (u >= this.wordsInUse) return fromIndex;
-var word = ~this.words[u] & (-1 << fromIndex);
-while (true) {
-if (word != 0) return (u * 32) + Integer.numberOfTrailingZeros (word);
-if (++u == this.wordsInUse) return this.wordsInUse * 32;
-word = ~this.words[u];
-}
-}, "~N");
-Clazz.defineMethod (c$, "length", 
-function () {
-if (this.wordsInUse == 0) return 0;
-return 32 * (this.wordsInUse - 1) + (32 - Integer.numberOfLeadingZeros (this.words[this.wordsInUse - 1]));
-});
-Clazz.defineMethod (c$, "isEmpty", 
-function () {
-return this.wordsInUse == 0;
-});
-Clazz.defineMethod (c$, "intersects", 
-function (set) {
-for (var i = Math.min (this.wordsInUse, set.wordsInUse) - 1; i >= 0; i--) if ((this.words[i] & set.words[i]) != 0) return true;
-
-return false;
-}, "javajs.util.BS");
-Clazz.defineMethod (c$, "cardinality", 
-function () {
-var sum = 0;
-for (var i = 0; i < this.wordsInUse; i++) sum += Integer.bitCount (this.words[i]);
-
-return sum;
-});
-Clazz.defineMethod (c$, "and", 
-function (set) {
-if (this === set) return;
-while (this.wordsInUse > set.wordsInUse) this.words[--this.wordsInUse] = 0;
-
-for (var i = 0; i < this.wordsInUse; i++) this.words[i] &= set.words[i];
-
-this.recalculateWordsInUse ();
-}, "javajs.util.BS");
-Clazz.defineMethod (c$, "or", 
-function (set) {
-if (this === set) return;
-var wordsInCommon = Math.min (this.wordsInUse, set.wordsInUse);
-if (this.wordsInUse < set.wordsInUse) {
-this.ensureCapacity (set.wordsInUse);
-this.wordsInUse = set.wordsInUse;
-}for (var i = 0; i < wordsInCommon; i++) this.words[i] |= set.words[i];
-
-if (wordsInCommon < set.wordsInUse) System.arraycopy (set.words, wordsInCommon, this.words, wordsInCommon, this.wordsInUse - wordsInCommon);
-}, "javajs.util.BS");
-Clazz.defineMethod (c$, "xor", 
-function (set) {
-var wordsInCommon = Math.min (this.wordsInUse, set.wordsInUse);
-if (this.wordsInUse < set.wordsInUse) {
-this.ensureCapacity (set.wordsInUse);
-this.wordsInUse = set.wordsInUse;
-}for (var i = 0; i < wordsInCommon; i++) this.words[i] ^= set.words[i];
-
-if (wordsInCommon < set.wordsInUse) System.arraycopy (set.words, wordsInCommon, this.words, wordsInCommon, set.wordsInUse - wordsInCommon);
-this.recalculateWordsInUse ();
-}, "javajs.util.BS");
-Clazz.defineMethod (c$, "andNot", 
-function (set) {
-for (var i = Math.min (this.wordsInUse, set.wordsInUse) - 1; i >= 0; i--) this.words[i] &= ~set.words[i];
-
-this.recalculateWordsInUse ();
-}, "javajs.util.BS");
-Clazz.overrideMethod (c$, "hashCode", 
-function () {
-var h = 1234;
-for (var i = this.wordsInUse; --i >= 0; ) h ^= this.words[i] * (i + 1);
-
-return ((h >> 32) ^ h);
-});
-Clazz.defineMethod (c$, "size", 
-function () {
-return this.words.length * 32;
-});
-Clazz.overrideMethod (c$, "equals", 
-function (obj) {
-if (!(Clazz.instanceOf (obj, javajs.util.BS))) return false;
-if (this === obj) return true;
-var set = obj;
-if (this.wordsInUse != set.wordsInUse) return false;
-for (var i = 0; i < this.wordsInUse; i++) if (this.words[i] != set.words[i]) return false;
-
-return true;
-}, "~O");
-Clazz.overrideMethod (c$, "clone", 
-function () {
-if (!this.sizeIsSticky && this.wordsInUse != this.words.length) this.setLength (this.wordsInUse);
-return javajs.util.BS.copy (this);
-});
-Clazz.defineMethod (c$, "setLength", 
-($fz = function (n) {
-var a =  Clazz.newIntArray (n, 0);
-System.arraycopy (this.words, 0, a, 0, Math.min (this.wordsInUse, n));
-this.words = a;
-}, $fz.isPrivate = true, $fz), "~N");
-Clazz.overrideMethod (c$, "toString", 
-function () {
-return javajs.util.BS.escape (this, '{', '}');
-});
-c$.copy = Clazz.defineMethod (c$, "copy", 
-function (bitsetToCopy) {
-var bs;
-{
-bs = Clazz.clone(bitsetToCopy);
-}var wordCount = bitsetToCopy.wordsInUse;
-if (wordCount == 0) {
-bs.words = javajs.util.BS.emptyBitmap;
-} else {
-bs.words =  Clazz.newIntArray (bs.wordsInUse = wordCount, 0);
-System.arraycopy (bitsetToCopy.words, 0, bs.words, 0, wordCount);
-}return bs;
-}, "javajs.util.BS");
-Clazz.defineMethod (c$, "cardinalityN", 
-function (max) {
-var n = this.cardinality ();
-for (var i = this.length (); --i >= max; ) if (this.get (i)) n--;
-
-return n;
-}, "~N");
-Clazz.overrideMethod (c$, "toJSON", 
-function () {
-var numBits = (this.wordsInUse > 128) ? this.cardinality () : this.wordsInUse * 32;
-var b = javajs.util.SB.newN (6 * numBits + 2);
-b.appendC ('[');
-var i = this.nextSetBit (0);
-if (i != -1) {
-b.appendI (i);
-for (i = this.nextSetBit (i + 1); i >= 0; i = this.nextSetBit (i + 1)) {
-var endOfRun = this.nextClearBit (i);
-do {
-b.append (", ").appendI (i);
-} while (++i < endOfRun);
-}
-}b.appendC (']');
-return b.toString ();
-});
-c$.escape = Clazz.defineMethod (c$, "escape", 
-function (bs, chOpen, chClose) {
-if (bs == null) return chOpen + "{}" + chClose;
-var s =  new javajs.util.SB ();
-s.append (chOpen + "{");
-var imax = bs.length ();
-var iLast = -1;
-var iFirst = -2;
-var i = -1;
-while (++i <= imax) {
-var isSet = bs.get (i);
-if (i == imax || iLast >= 0 && !isSet) {
-if (iLast >= 0 && iFirst != iLast) s.append ((iFirst == iLast - 1 ? " " : ":") + iLast);
-if (i == imax) break;
-iLast = -1;
-}if (bs.get (i)) {
-if (iLast < 0) {
-s.append ((iFirst == -2 ? "" : " ") + i);
-iFirst = i;
-}iLast = i;
-}}
-s.append ("}").appendC (chClose);
-return s.toString ();
-}, "javajs.util.BS,~S,~S");
-c$.unescape = Clazz.defineMethod (c$, "unescape", 
-function (str) {
-var ch;
-var len;
-if (str == null || (len = (str = str.trim ()).length) < 4 || str.equalsIgnoreCase ("({null})") || (ch = str.charAt (0)) != '(' && ch != '[' || str.charAt (len - 1) != (ch == '(' ? ')' : ']') || str.charAt (1) != '{' || str.indexOf ('}') != len - 2) return null;
-len -= 2;
-for (var i = len; --i >= 2; ) if (!javajs.util.PT.isDigit (ch = str.charAt (i)) && ch != ' ' && ch != '\t' && ch != ':') return null;
-
-var lastN = len;
-while (javajs.util.PT.isDigit (str.charAt (--lastN))) {
-}
-if (++lastN == len) lastN = 0;
- else try {
-lastN = Integer.parseInt (str.substring (lastN, len));
-} catch (e) {
-if (Clazz.exceptionOf (e, NumberFormatException)) {
-return null;
-} else {
-throw e;
-}
-}
-var bs = javajs.util.BS.newN (lastN);
-lastN = -1;
-var iPrev = -1;
-var iThis = -2;
-for (var i = 2; i <= len; i++) {
-switch (ch = str.charAt (i)) {
-case '\t':
-case ' ':
-case '}':
-if (iThis < 0) break;
-if (iThis < lastN) return null;
-lastN = iThis;
-if (iPrev < 0) iPrev = iThis;
-bs.setBits (iPrev, iThis + 1);
-iPrev = -1;
-iThis = -2;
-break;
-case ':':
-iPrev = lastN = iThis;
-iThis = -2;
-break;
-default:
-if (javajs.util.PT.isDigit (ch)) {
-if (iThis < 0) iThis = 0;
-iThis = (iThis * 10) + (ch.charCodeAt (0) - 48);
-}}
-}
-return (iPrev >= 0 ? null : bs);
-}, "~S");
-Clazz.defineStatics (c$,
-"ADDRESS_BITS_PER_WORD", 5,
-"BITS_PER_WORD", 32,
-"WORD_MASK", 0xffffffff,
-"emptyBitmap",  Clazz.newIntArray (0, 0));
-});
+Clazz.declarePackage ("javajs.util");\r
+Clazz.load (["javajs.api.JSONEncodable"], "javajs.util.BS", ["java.lang.IndexOutOfBoundsException", "$.NegativeArraySizeException", "javajs.util.PT", "$.SB"], function () {\r
+c$ = Clazz.decorateAsClass (function () {\r
+this.words = null;\r
+this.wordsInUse = 0;\r
+this.sizeIsSticky = false;\r
+Clazz.instantialize (this, arguments);\r
+}, javajs.util, "BS", null, [Cloneable, javajs.api.JSONEncodable]);\r
+c$.wordIndex = Clazz.defineMethod (c$, "wordIndex", \r
+($fz = function (bitIndex) {\r
+return bitIndex >> 5;\r
+}, $fz.isPrivate = true, $fz), "~N");\r
+Clazz.defineMethod (c$, "recalculateWordsInUse", \r
+($fz = function () {\r
+var i;\r
+for (i = this.wordsInUse - 1; i >= 0; i--) if (this.words[i] != 0) break;\r
+\r
+this.wordsInUse = i + 1;\r
+}, $fz.isPrivate = true, $fz));\r
+Clazz.makeConstructor (c$, \r
+function () {\r
+this.initWords (32);\r
+this.sizeIsSticky = false;\r
+});\r
+c$.newN = Clazz.defineMethod (c$, "newN", \r
+function (nbits) {\r
+var bs =  new javajs.util.BS ();\r
+bs.init (nbits);\r
+return bs;\r
+}, "~N");\r
+Clazz.defineMethod (c$, "init", \r
+($fz = function (nbits) {\r
+if (nbits < 0) throw  new NegativeArraySizeException ("nbits < 0: " + nbits);\r
+this.initWords (nbits);\r
+this.sizeIsSticky = true;\r
+}, $fz.isPrivate = true, $fz), "~N");\r
+Clazz.defineMethod (c$, "initWords", \r
+($fz = function (nbits) {\r
+this.words =  Clazz.newIntArray (javajs.util.BS.wordIndex (nbits - 1) + 1, 0);\r
+}, $fz.isPrivate = true, $fz), "~N");\r
+Clazz.defineMethod (c$, "ensureCapacity", \r
+($fz = function (wordsRequired) {\r
+if (this.words.length < wordsRequired) {\r
+var request = Math.max (2 * this.words.length, wordsRequired);\r
+this.setLength (request);\r
+this.sizeIsSticky = false;\r
+}}, $fz.isPrivate = true, $fz), "~N");\r
+Clazz.defineMethod (c$, "expandTo", \r
+($fz = function (wordIndex) {\r
+var wordsRequired = wordIndex + 1;\r
+if (this.wordsInUse < wordsRequired) {\r
+this.ensureCapacity (wordsRequired);\r
+this.wordsInUse = wordsRequired;\r
+}}, $fz.isPrivate = true, $fz), "~N");\r
+Clazz.defineMethod (c$, "set", \r
+function (bitIndex) {\r
+if (bitIndex < 0) throw  new IndexOutOfBoundsException ("bitIndex < 0: " + bitIndex);\r
+var wordIndex = javajs.util.BS.wordIndex (bitIndex);\r
+this.expandTo (wordIndex);\r
+this.words[wordIndex] |= (1 << bitIndex);\r
+}, "~N");\r
+Clazz.defineMethod (c$, "setBitTo", \r
+function (bitIndex, value) {\r
+if (value) this.set (bitIndex);\r
+ else this.clear (bitIndex);\r
+}, "~N,~B");\r
+Clazz.defineMethod (c$, "setBits", \r
+function (fromIndex, toIndex) {\r
+if (fromIndex == toIndex) return;\r
+var startWordIndex = javajs.util.BS.wordIndex (fromIndex);\r
+var endWordIndex = javajs.util.BS.wordIndex (toIndex - 1);\r
+this.expandTo (endWordIndex);\r
+var firstWordMask = -1 << fromIndex;\r
+var lastWordMask = -1 >>> -toIndex;\r
+if (startWordIndex == endWordIndex) {\r
+this.words[startWordIndex] |= (firstWordMask & lastWordMask);\r
+} else {\r
+this.words[startWordIndex] |= firstWordMask;\r
+for (var i = startWordIndex + 1; i < endWordIndex; i++) this.words[i] = -1;\r
+\r
+this.words[endWordIndex] |= lastWordMask;\r
+}}, "~N,~N");\r
+Clazz.defineMethod (c$, "clear", \r
+function (bitIndex) {\r
+if (bitIndex < 0) throw  new IndexOutOfBoundsException ("bitIndex < 0: " + bitIndex);\r
+var wordIndex = javajs.util.BS.wordIndex (bitIndex);\r
+if (wordIndex >= this.wordsInUse) return;\r
+this.words[wordIndex] &= ~(1 << bitIndex);\r
+this.recalculateWordsInUse ();\r
+}, "~N");\r
+Clazz.defineMethod (c$, "clearBits", \r
+function (fromIndex, toIndex) {\r
+if (fromIndex == toIndex) return;\r
+var startWordIndex = javajs.util.BS.wordIndex (fromIndex);\r
+if (startWordIndex >= this.wordsInUse) return;\r
+var endWordIndex = javajs.util.BS.wordIndex (toIndex - 1);\r
+if (endWordIndex >= this.wordsInUse) {\r
+toIndex = this.length ();\r
+endWordIndex = this.wordsInUse - 1;\r
+}var firstWordMask = -1 << fromIndex;\r
+var lastWordMask = -1 >>> -toIndex;\r
+if (startWordIndex == endWordIndex) {\r
+this.words[startWordIndex] &= ~(firstWordMask & lastWordMask);\r
+} else {\r
+this.words[startWordIndex] &= ~firstWordMask;\r
+for (var i = startWordIndex + 1; i < endWordIndex; i++) this.words[i] = 0;\r
+\r
+this.words[endWordIndex] &= ~lastWordMask;\r
+}this.recalculateWordsInUse ();\r
+}, "~N,~N");\r
+Clazz.defineMethod (c$, "clearAll", \r
+function () {\r
+while (this.wordsInUse > 0) this.words[--this.wordsInUse] = 0;\r
+\r
+});\r
+Clazz.defineMethod (c$, "get", \r
+function (bitIndex) {\r
+if (bitIndex < 0) throw  new IndexOutOfBoundsException ("bitIndex < 0: " + bitIndex);\r
+var wordIndex = javajs.util.BS.wordIndex (bitIndex);\r
+return (wordIndex < this.wordsInUse) && ((this.words[wordIndex] & (1 << bitIndex)) != 0);\r
+}, "~N");\r
+Clazz.defineMethod (c$, "nextSetBit", \r
+function (fromIndex) {\r
+if (fromIndex < 0) throw  new IndexOutOfBoundsException ("fromIndex < 0: " + fromIndex);\r
+var u = javajs.util.BS.wordIndex (fromIndex);\r
+if (u >= this.wordsInUse) return -1;\r
+var word = this.words[u] & (-1 << fromIndex);\r
+while (true) {\r
+if (word != 0) return (u * 32) + Integer.numberOfTrailingZeros (word);\r
+if (++u == this.wordsInUse) return -1;\r
+word = this.words[u];\r
+}\r
+}, "~N");\r
+Clazz.defineMethod (c$, "nextClearBit", \r
+function (fromIndex) {\r
+if (fromIndex < 0) throw  new IndexOutOfBoundsException ("fromIndex < 0: " + fromIndex);\r
+var u = javajs.util.BS.wordIndex (fromIndex);\r
+if (u >= this.wordsInUse) return fromIndex;\r
+var word = ~this.words[u] & (-1 << fromIndex);\r
+while (true) {\r
+if (word != 0) return (u * 32) + Integer.numberOfTrailingZeros (word);\r
+if (++u == this.wordsInUse) return this.wordsInUse * 32;\r
+word = ~this.words[u];\r
+}\r
+}, "~N");\r
+Clazz.defineMethod (c$, "length", \r
+function () {\r
+if (this.wordsInUse == 0) return 0;\r
+return 32 * (this.wordsInUse - 1) + (32 - Integer.numberOfLeadingZeros (this.words[this.wordsInUse - 1]));\r
+});\r
+Clazz.defineMethod (c$, "isEmpty", \r
+function () {\r
+return this.wordsInUse == 0;\r
+});\r
+Clazz.defineMethod (c$, "intersects", \r
+function (set) {\r
+for (var i = Math.min (this.wordsInUse, set.wordsInUse) - 1; i >= 0; i--) if ((this.words[i] & set.words[i]) != 0) return true;\r
+\r
+return false;\r
+}, "javajs.util.BS");\r
+Clazz.defineMethod (c$, "cardinality", \r
+function () {\r
+var sum = 0;\r
+for (var i = 0; i < this.wordsInUse; i++) sum += Integer.bitCount (this.words[i]);\r
+\r
+return sum;\r
+});\r
+Clazz.defineMethod (c$, "and", \r
+function (set) {\r
+if (this === set) return;\r
+while (this.wordsInUse > set.wordsInUse) this.words[--this.wordsInUse] = 0;\r
+\r
+for (var i = 0; i < this.wordsInUse; i++) this.words[i] &= set.words[i];\r
+\r
+this.recalculateWordsInUse ();\r
+}, "javajs.util.BS");\r
+Clazz.defineMethod (c$, "or", \r
+function (set) {\r
+if (this === set) return;\r
+var wordsInCommon = Math.min (this.wordsInUse, set.wordsInUse);\r
+if (this.wordsInUse < set.wordsInUse) {\r
+this.ensureCapacity (set.wordsInUse);\r
+this.wordsInUse = set.wordsInUse;\r
+}for (var i = 0; i < wordsInCommon; i++) this.words[i] |= set.words[i];\r
+\r
+if (wordsInCommon < set.wordsInUse) System.arraycopy (set.words, wordsInCommon, this.words, wordsInCommon, this.wordsInUse - wordsInCommon);\r
+}, "javajs.util.BS");\r
+Clazz.defineMethod (c$, "xor", \r
+function (set) {\r
+var wordsInCommon = Math.min (this.wordsInUse, set.wordsInUse);\r
+if (this.wordsInUse < set.wordsInUse) {\r
+this.ensureCapacity (set.wordsInUse);\r
+this.wordsInUse = set.wordsInUse;\r
+}for (var i = 0; i < wordsInCommon; i++) this.words[i] ^= set.words[i];\r
+\r
+if (wordsInCommon < set.wordsInUse) System.arraycopy (set.words, wordsInCommon, this.words, wordsInCommon, set.wordsInUse - wordsInCommon);\r
+this.recalculateWordsInUse ();\r
+}, "javajs.util.BS");\r
+Clazz.defineMethod (c$, "andNot", \r
+function (set) {\r
+for (var i = Math.min (this.wordsInUse, set.wordsInUse) - 1; i >= 0; i--) this.words[i] &= ~set.words[i];\r
+\r
+this.recalculateWordsInUse ();\r
+}, "javajs.util.BS");\r
+Clazz.overrideMethod (c$, "hashCode", \r
+function () {\r
+var h = 1234;\r
+for (var i = this.wordsInUse; --i >= 0; ) h ^= this.words[i] * (i + 1);\r
+\r
+return ((h >> 32) ^ h);\r
+});\r
+Clazz.defineMethod (c$, "size", \r
+function () {\r
+return this.words.length * 32;\r
+});\r
+Clazz.overrideMethod (c$, "equals", \r
+function (obj) {\r
+if (!(Clazz.instanceOf (obj, javajs.util.BS))) return false;\r
+if (this === obj) return true;\r
+var set = obj;\r
+if (this.wordsInUse != set.wordsInUse) return false;\r
+for (var i = 0; i < this.wordsInUse; i++) if (this.words[i] != set.words[i]) return false;\r
+\r
+return true;\r
+}, "~O");\r
+Clazz.overrideMethod (c$, "clone", \r
+function () {\r
+if (!this.sizeIsSticky && this.wordsInUse != this.words.length) this.setLength (this.wordsInUse);\r
+return javajs.util.BS.copy (this);\r
+});\r
+Clazz.defineMethod (c$, "setLength", \r
+($fz = function (n) {\r
+var a =  Clazz.newIntArray (n, 0);\r
+System.arraycopy (this.words, 0, a, 0, Math.min (this.wordsInUse, n));\r
+this.words = a;\r
+}, $fz.isPrivate = true, $fz), "~N");\r
+Clazz.overrideMethod (c$, "toString", \r
+function () {\r
+return javajs.util.BS.escape (this, '{', '}');\r
+});\r
+c$.copy = Clazz.defineMethod (c$, "copy", \r
+function (bitsetToCopy) {\r
+var bs;\r
+{\r
+bs = Clazz.clone(bitsetToCopy);\r
+}var wordCount = bitsetToCopy.wordsInUse;\r
+if (wordCount == 0) {\r
+bs.words = javajs.util.BS.emptyBitmap;\r
+} else {\r
+bs.words =  Clazz.newIntArray (bs.wordsInUse = wordCount, 0);\r
+System.arraycopy (bitsetToCopy.words, 0, bs.words, 0, wordCount);\r
+}return bs;\r
+}, "javajs.util.BS");\r
+Clazz.defineMethod (c$, "cardinalityN", \r
+function (max) {\r
+var n = this.cardinality ();\r
+for (var i = this.length (); --i >= max; ) if (this.get (i)) n--;\r
+\r
+return n;\r
+}, "~N");\r
+Clazz.overrideMethod (c$, "toJSON", \r
+function () {\r
+var numBits = (this.wordsInUse > 128) ? this.cardinality () : this.wordsInUse * 32;\r
+var b = javajs.util.SB.newN (6 * numBits + 2);\r
+b.appendC ('[');\r
+var i = this.nextSetBit (0);\r
+if (i != -1) {\r
+b.appendI (i);\r
+for (i = this.nextSetBit (i + 1); i >= 0; i = this.nextSetBit (i + 1)) {\r
+var endOfRun = this.nextClearBit (i);\r
+do {\r
+b.append (", ").appendI (i);\r
+} while (++i < endOfRun);\r
+}\r
+}b.appendC (']');\r
+return b.toString ();\r
+});\r
+c$.escape = Clazz.defineMethod (c$, "escape", \r
+function (bs, chOpen, chClose) {\r
+if (bs == null) return chOpen + "{}" + chClose;\r
+var s =  new javajs.util.SB ();\r
+s.append (chOpen + "{");\r
+var imax = bs.length ();\r
+var iLast = -1;\r
+var iFirst = -2;\r
+var i = -1;\r
+while (++i <= imax) {\r
+var isSet = bs.get (i);\r
+if (i == imax || iLast >= 0 && !isSet) {\r
+if (iLast >= 0 && iFirst != iLast) s.append ((iFirst == iLast - 1 ? " " : ":") + iLast);\r
+if (i == imax) break;\r
+iLast = -1;\r
+}if (bs.get (i)) {\r
+if (iLast < 0) {\r
+s.append ((iFirst == -2 ? "" : " ") + i);\r
+iFirst = i;\r
+}iLast = i;\r
+}}\r
+s.append ("}").appendC (chClose);\r
+return s.toString ();\r
+}, "javajs.util.BS,~S,~S");\r
+c$.unescape = Clazz.defineMethod (c$, "unescape", \r
+function (str) {\r
+var ch;\r
+var len;\r
+if (str == null || (len = (str = str.trim ()).length) < 4 || str.equalsIgnoreCase ("({null})") || (ch = str.charAt (0)) != '(' && ch != '[' || str.charAt (len - 1) != (ch == '(' ? ')' : ']') || str.charAt (1) != '{' || str.indexOf ('}') != len - 2) return null;\r
+len -= 2;\r
+for (var i = len; --i >= 2; ) if (!javajs.util.PT.isDigit (ch = str.charAt (i)) && ch != ' ' && ch != '\t' && ch != ':') return null;\r
+\r
+var lastN = len;\r
+while (javajs.util.PT.isDigit (str.charAt (--lastN))) {\r
+}\r
+if (++lastN == len) lastN = 0;\r
+ else try {\r
+lastN = Integer.parseInt (str.substring (lastN, len));\r
+} catch (e) {\r
+if (Clazz.exceptionOf (e, NumberFormatException)) {\r
+return null;\r
+} else {\r
+throw e;\r
+}\r
+}\r
+var bs = javajs.util.BS.newN (lastN);\r
+lastN = -1;\r
+var iPrev = -1;\r
+var iThis = -2;\r
+for (var i = 2; i <= len; i++) {\r
+switch (ch = str.charAt (i)) {\r
+case '\t':\r
+case ' ':\r
+case '}':\r
+if (iThis < 0) break;\r
+if (iThis < lastN) return null;\r
+lastN = iThis;\r
+if (iPrev < 0) iPrev = iThis;\r
+bs.setBits (iPrev, iThis + 1);\r
+iPrev = -1;\r
+iThis = -2;\r
+break;\r
+case ':':\r
+iPrev = lastN = iThis;\r
+iThis = -2;\r
+break;\r
+default:\r
+if (javajs.util.PT.isDigit (ch)) {\r
+if (iThis < 0) iThis = 0;\r
+iThis = (iThis * 10) + (ch.charCodeAt (0) - 48);\r
+}}\r
+}\r
+return (iPrev >= 0 ? null : bs);\r
+}, "~S");\r
+Clazz.defineStatics (c$,\r
+"ADDRESS_BITS_PER_WORD", 5,\r
+"BITS_PER_WORD", 32,\r
+"WORD_MASK", 0xffffffff,\r
+"emptyBitmap",  Clazz.newIntArray (0, 0));\r
+});\r