{"ScriptPreparationCode":"window.TEST_ITERATIONS = 200;\r\nwindow.Queue = function () {\r\n const storage = {};\r\n let front = 0;\r\n let size = 0;\r\n\r\n const enqueue = function (item) {\r\n storage[this.size \u002B this.front] = item;\r\n this.size\u002B\u002B;\r\n };\r\n\r\n const dequeue = function () {\r\n if (this.size === 0) return undefined;\r\n\r\n const item = storage[this.front];\r\n delete storage[this.front];\r\n this.size--;\r\n if (this.size === 0) this.front = 0;\r\n else this.front\u002B\u002B;\r\n return item;\r\n };\r\n\r\n const getFront = function () {\r\n if (this.size === 0) return undefined;\r\n return storage[this.front];\r\n };\r\n\r\n const getRear = function () {\r\n if (this.size === 0) return undefined;\r\n return storage[this.size \u002B this.front - 1];\r\n };\r\n\r\n const isEmpty = function () {\r\n return this.size === 0;\r\n };\r\n\r\n return { size, front, enqueue, dequeue, isEmpty, getFront, getRear };\r\n};\r\n","TestCases":[{"Name":"Object","Code":"const queue = Queue();\r\n\r\nfor (let i = 0; i \u003C= TEST_ITERATIONS; i\u002B\u002B) {\r\n \r\n queue.enqueue(Math.random());\r\n queue.enqueue(Math.random());\r\n queue.enqueue(Math.random());\r\n queue.enqueue(Math.random());\r\n queue.isEmpty();\r\n\r\n queue.dequeue(Math.random());\r\n queue.enqueue(Math.random());\r\n queue.dequeue(Math.random());\r\n queue.enqueue(Math.random());\r\n\r\n queue.getFront();\r\n queue.getRear();\r\n}\r\n","IsDeferred":false},{"Name":"Array","Code":"const queue = [];\r\n\r\nfor (let i = 0; i \u003C= TEST_ITERATIONS; i\u002B\u002B) {\r\n queue.unshift(Math.random());\r\n queue.unshift(Math.random());\r\n queue.unshift(Math.random());\r\n queue.unshift(Math.random());\r\n void (queue.length == 0);\r\n\r\n queue.pop(Math.random());\r\n queue.unshift(Math.random());\r\n queue.pop(Math.random());\r\n queue.unshift(Math.random());\r\n\r\n void (queue[queue.length-1]);\r\n void (queue[0]);\r\n}","IsDeferred":false}]}