4 * A queue that works by the FIFO (first in, first out) principle.
5 * It can store any type of data and has no fixed size.
6 * @author Tox, webcodesign.de
10 private var q
:Array = [];
16 public function Queue
() { }
19 public function dump
():void {
20 for (var i
:int = 0; i
< q
.length
; i
++) {
21 trace
("[" + i
+ "]=",q
[i
]);
26 * Writes data to the end of the queue.
27 * @param d Data to write, can be of any type.
29 public function write
(d
:*):void {q
.push
(d
);}
32 * Reads data from the beginning of the queue.
33 * @return Data stored at the beginning of the queue.
35 public function read
():* { l
--; return (empty
) ? null : q
.shift
(); }
38 * Checks if the queue is empty and returns the result.
40 public function get empty
():Boolean { return (q
.length
<= 0); }
43 * Returns the data of the first queue element without removing it.
44 * @return Data of the first queue element.
46 public function spy
():* {return (empty
) ? null : q
[0];}