Module:Sandbox/Queue

Queue = {} Queue.__index = Queue

function Queue:new local instance = {} instance._et = {} setmetatable(instance,Queue) return instance end

function Queue:push(...) if ... then local targs = {...} for _,v in ipairs(targs)do table.insert(self._et, v)		end end end

function Queue:pop(num) local num = num or 1 local entries = {}

for i = 1, num do		if #self._et ~= 0 then table.insert(entries, self._et[1]) table.remove(self._et,1) else break end end return unpack(entries) end

function Queue:peek if self._et[1] == nil then return "nil" else return self._et[1] end end

function Queue:is_empty return #self._et == 0 end

function Queue:size return #self._et end

function Queue:list t = table.concat(self._et, ",") mw.log(t) end

return Queue