1 Clazz.declarePackage ("jssun.misc");
2 Clazz.load (["java.util.Enumeration"], ["jssun.misc.Queue", "$.LIFOQueueEnumerator", "$.FIFOQueueEnumerator", "$.QueueElement"], ["java.util.NoSuchElementException", "swingjs.JSToolkit"], function () {
3 c$ = Clazz.decorateAsClass (function () {
7 Clazz.instantialize (this, arguments);
8 }, jssun.misc, "Queue");
9 Clazz.makeConstructor (c$,
12 Clazz.defineMethod (c$, "enqueue",
14 var newElt = new jssun.misc.QueueElement (obj);
15 if (this.head == null) {
20 newElt.next = this.head;
21 this.head.prev = newElt;
26 Clazz.defineMethod (c$, "dequeue",
28 return this.dequeue (0);
30 Clazz.defineMethod (c$, "dequeue",
32 while (this.tail == null) {
33 swingjs.JSToolkit.warn ("Cannot wait in Queue.java");
38 if (this.tail == null) {
41 this.tail.next = null;
45 Clazz.defineMethod (c$, "isEmpty",
47 return (this.tail == null);
49 Clazz.defineMethod (c$, "elements",
51 return new jssun.misc.LIFOQueueEnumerator (this);
53 Clazz.defineMethod (c$, "reverseElements",
55 return new jssun.misc.FIFOQueueEnumerator (this);
57 Clazz.defineMethod (c$, "dump",
59 System.err.println (">> " + msg);
60 System.err.println ("[" + this.length + " elt(s); head = " + (this.head == null ? "null" : (this.head.obj) + "") + " tail = " + (this.tail == null ? "null" : (this.tail.obj) + ""));
61 var cursor = this.head;
63 while (cursor != null) {
64 System.err.println (" " + cursor);
68 if (last !== this.tail) {
69 System.err.println (" tail != last: " + this.tail + ", " + last);
70 }System.err.println ("]");
72 c$ = Clazz.decorateAsClass (function () {
75 Clazz.instantialize (this, arguments);
76 }, jssun.misc, "FIFOQueueEnumerator", null, java.util.Enumeration);
77 Clazz.makeConstructor (c$,
81 }, "jssun.misc.Queue");
82 Clazz.overrideMethod (c$, "hasMoreElements",
84 return (this.cursor != null);
86 Clazz.overrideMethod (c$, "nextElement",
89 if (this.cursor != null) {
90 var result = this.cursor;
91 this.cursor = this.cursor.prev;
93 }}throw new java.util.NoSuchElementException ("FIFOQueueEnumerator");
95 c$ = Clazz.decorateAsClass (function () {
98 Clazz.instantialize (this, arguments);
99 }, jssun.misc, "LIFOQueueEnumerator", null, java.util.Enumeration);
100 Clazz.makeConstructor (c$,
103 this.cursor = q.head;
104 }, "jssun.misc.Queue");
105 Clazz.overrideMethod (c$, "hasMoreElements",
107 return (this.cursor != null);
109 Clazz.overrideMethod (c$, "nextElement",
112 if (this.cursor != null) {
113 var result = this.cursor;
114 this.cursor = this.cursor.next;
116 }}throw new java.util.NoSuchElementException ("LIFOQueueEnumerator");
118 c$ = Clazz.decorateAsClass (function () {
122 Clazz.instantialize (this, arguments);
123 }, jssun.misc, "QueueElement");
124 Clazz.makeConstructor (c$,
128 Clazz.overrideMethod (c$, "toString",
130 return "QueueElement[obj=" + this.obj + (this.prev == null ? " null" : " prev") + (this.next == null ? " null" : " next") + "]";