package QueueModule public module QueueModule static thistype last = null static thistype first = null static int count = 0 thistype prev construct() count++ if count == 1 last = this first = this else prev = first first = this ondestroy count-- last = this.prev static function getLast() returns thistype return last public module SingletonQueue static T array storage static int maxSize = 8190 static int fp = 0 static int rp = 0 static int size = 0 static function enqueue(T t) if size < maxSize size++ rp = (rp + 1) mod maxSize storage[rp] = t else error("Queue Overflow") static function dequeue() returns T if size > 0 size-- fp = (fp + 1) mod maxSize return storage[fp] else error("Queue empty") return null