X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=site%2Fswingjs%2Fj2s%2Fjssun%2Fmisc%2FQueue.js;fp=site%2Fswingjs%2Fj2s%2Fjssun%2Fmisc%2FQueue.js;h=3a09124da5b7c207ca6531c8689ba028b8d1ff89;hp=48a04633a1791dea655fbce46c37c6ce4306f8e2;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hpb=7301a2415adab88038b291fc54caeeb3a5a47a44 diff --git a/site/swingjs/j2s/jssun/misc/Queue.js b/site/swingjs/j2s/jssun/misc/Queue.js index 48a0463..3a09124 100644 --- a/site/swingjs/j2s/jssun/misc/Queue.js +++ b/site/swingjs/j2s/jssun/misc/Queue.js @@ -1,132 +1,132 @@ -Clazz.declarePackage ("jssun.misc"); -Clazz.load (["java.util.Enumeration"], ["jssun.misc.Queue", "$.LIFOQueueEnumerator", "$.FIFOQueueEnumerator", "$.QueueElement"], ["java.util.NoSuchElementException", "swingjs.JSToolkit"], function () { -c$ = Clazz.decorateAsClass (function () { -this.length = 0; -this.head = null; -this.tail = null; -Clazz.instantialize (this, arguments); -}, jssun.misc, "Queue"); -Clazz.makeConstructor (c$, -function () { -}); -Clazz.defineMethod (c$, "enqueue", -function (obj) { -var newElt = new jssun.misc.QueueElement (obj); -if (this.head == null) { -this.head = newElt; -this.tail = newElt; -this.length = 1; -} else { -newElt.next = this.head; -this.head.prev = newElt; -this.head = newElt; -this.length++; -}this.notify (); -}, "~O"); -Clazz.defineMethod (c$, "dequeue", -function () { -return this.dequeue (0); -}); -Clazz.defineMethod (c$, "dequeue", -function (timeOut) { -while (this.tail == null) { -swingjs.JSToolkit.warn ("Cannot wait in Queue.java"); -this.wait (timeOut); -} -var elt = this.tail; -this.tail = elt.prev; -if (this.tail == null) { -this.head = null; -} else { -this.tail.next = null; -}this.length--; -return elt.obj; -}, "~N"); -Clazz.defineMethod (c$, "isEmpty", -function () { -return (this.tail == null); -}); -Clazz.defineMethod (c$, "elements", -function () { -return new jssun.misc.LIFOQueueEnumerator (this); -}); -Clazz.defineMethod (c$, "reverseElements", -function () { -return new jssun.misc.FIFOQueueEnumerator (this); -}); -Clazz.defineMethod (c$, "dump", -function (msg) { -System.err.println (">> " + msg); -System.err.println ("[" + this.length + " elt(s); head = " + (this.head == null ? "null" : (this.head.obj) + "") + " tail = " + (this.tail == null ? "null" : (this.tail.obj) + "")); -var cursor = this.head; -var last = null; -while (cursor != null) { -System.err.println (" " + cursor); -last = cursor; -cursor = cursor.next; -} -if (last !== this.tail) { -System.err.println (" tail != last: " + this.tail + ", " + last); -}System.err.println ("]"); -}, "~S"); -c$ = Clazz.decorateAsClass (function () { -this.queue = null; -this.cursor = null; -Clazz.instantialize (this, arguments); -}, jssun.misc, "FIFOQueueEnumerator", null, java.util.Enumeration); -Clazz.makeConstructor (c$, -function (q) { -this.queue = q; -this.cursor = q.tail; -}, "jssun.misc.Queue"); -Clazz.overrideMethod (c$, "hasMoreElements", -function () { -return (this.cursor != null); -}); -Clazz.overrideMethod (c$, "nextElement", -function () { -{ -if (this.cursor != null) { -var result = this.cursor; -this.cursor = this.cursor.prev; -return result.obj; -}}throw new java.util.NoSuchElementException ("FIFOQueueEnumerator"); -}); -c$ = Clazz.decorateAsClass (function () { -this.queue = null; -this.cursor = null; -Clazz.instantialize (this, arguments); -}, jssun.misc, "LIFOQueueEnumerator", null, java.util.Enumeration); -Clazz.makeConstructor (c$, -function (q) { -this.queue = q; -this.cursor = q.head; -}, "jssun.misc.Queue"); -Clazz.overrideMethod (c$, "hasMoreElements", -function () { -return (this.cursor != null); -}); -Clazz.overrideMethod (c$, "nextElement", -function () { -{ -if (this.cursor != null) { -var result = this.cursor; -this.cursor = this.cursor.next; -return result.obj; -}}throw new java.util.NoSuchElementException ("LIFOQueueEnumerator"); -}); -c$ = Clazz.decorateAsClass (function () { -this.next = null; -this.prev = null; -this.obj = null; -Clazz.instantialize (this, arguments); -}, jssun.misc, "QueueElement"); -Clazz.makeConstructor (c$, -function (obj) { -this.obj = obj; -}, "~O"); -Clazz.overrideMethod (c$, "toString", -function () { -return "QueueElement[obj=" + this.obj + (this.prev == null ? " null" : " prev") + (this.next == null ? " null" : " next") + "]"; -}); -}); +Clazz.declarePackage ("jssun.misc"); +Clazz.load (["java.util.Enumeration"], ["jssun.misc.Queue", "$.LIFOQueueEnumerator", "$.FIFOQueueEnumerator", "$.QueueElement"], ["java.util.NoSuchElementException", "swingjs.JSToolkit"], function () { +c$ = Clazz.decorateAsClass (function () { +this.length = 0; +this.head = null; +this.tail = null; +Clazz.instantialize (this, arguments); +}, jssun.misc, "Queue"); +Clazz.makeConstructor (c$, +function () { +}); +Clazz.defineMethod (c$, "enqueue", +function (obj) { +var newElt = new jssun.misc.QueueElement (obj); +if (this.head == null) { +this.head = newElt; +this.tail = newElt; +this.length = 1; +} else { +newElt.next = this.head; +this.head.prev = newElt; +this.head = newElt; +this.length++; +}this.notify (); +}, "~O"); +Clazz.defineMethod (c$, "dequeue", +function () { +return this.dequeue (0); +}); +Clazz.defineMethod (c$, "dequeue", +function (timeOut) { +while (this.tail == null) { +swingjs.JSToolkit.warn ("Cannot wait in Queue.java"); +this.wait (timeOut); +} +var elt = this.tail; +this.tail = elt.prev; +if (this.tail == null) { +this.head = null; +} else { +this.tail.next = null; +}this.length--; +return elt.obj; +}, "~N"); +Clazz.defineMethod (c$, "isEmpty", +function () { +return (this.tail == null); +}); +Clazz.defineMethod (c$, "elements", +function () { +return new jssun.misc.LIFOQueueEnumerator (this); +}); +Clazz.defineMethod (c$, "reverseElements", +function () { +return new jssun.misc.FIFOQueueEnumerator (this); +}); +Clazz.defineMethod (c$, "dump", +function (msg) { +System.err.println (">> " + msg); +System.err.println ("[" + this.length + " elt(s); head = " + (this.head == null ? "null" : (this.head.obj) + "") + " tail = " + (this.tail == null ? "null" : (this.tail.obj) + "")); +var cursor = this.head; +var last = null; +while (cursor != null) { +System.err.println (" " + cursor); +last = cursor; +cursor = cursor.next; +} +if (last !== this.tail) { +System.err.println (" tail != last: " + this.tail + ", " + last); +}System.err.println ("]"); +}, "~S"); +c$ = Clazz.decorateAsClass (function () { +this.queue = null; +this.cursor = null; +Clazz.instantialize (this, arguments); +}, jssun.misc, "FIFOQueueEnumerator", null, java.util.Enumeration); +Clazz.makeConstructor (c$, +function (q) { +this.queue = q; +this.cursor = q.tail; +}, "jssun.misc.Queue"); +Clazz.overrideMethod (c$, "hasMoreElements", +function () { +return (this.cursor != null); +}); +Clazz.overrideMethod (c$, "nextElement", +function () { +{ +if (this.cursor != null) { +var result = this.cursor; +this.cursor = this.cursor.prev; +return result.obj; +}}throw new java.util.NoSuchElementException ("FIFOQueueEnumerator"); +}); +c$ = Clazz.decorateAsClass (function () { +this.queue = null; +this.cursor = null; +Clazz.instantialize (this, arguments); +}, jssun.misc, "LIFOQueueEnumerator", null, java.util.Enumeration); +Clazz.makeConstructor (c$, +function (q) { +this.queue = q; +this.cursor = q.head; +}, "jssun.misc.Queue"); +Clazz.overrideMethod (c$, "hasMoreElements", +function () { +return (this.cursor != null); +}); +Clazz.overrideMethod (c$, "nextElement", +function () { +{ +if (this.cursor != null) { +var result = this.cursor; +this.cursor = this.cursor.next; +return result.obj; +}}throw new java.util.NoSuchElementException ("LIFOQueueEnumerator"); +}); +c$ = Clazz.decorateAsClass (function () { +this.next = null; +this.prev = null; +this.obj = null; +Clazz.instantialize (this, arguments); +}, jssun.misc, "QueueElement"); +Clazz.makeConstructor (c$, +function (obj) { +this.obj = obj; +}, "~O"); +Clazz.overrideMethod (c$, "toString", +function () { +return "QueueElement[obj=" + this.obj + (this.prev == null ? " null" : " prev") + (this.next == null ? " null" : " next") + "]"; +}); +});