Module:FunList/Iterators: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 33: Line 33:
function Enumerator:getEnumerator()
function Enumerator:getEnumerator()
error('Not implemented in base class.')
error('Not implemented in base class.')
end
function Enumerator:reset()
enum.index = nil
enum.current = nil
end
end


Line 39: Line 44:
-- Get or create clean enumerator
-- Get or create clean enumerator
local enum = self:getEnumerator()
local enum = self:getEnumerator()
enum:reset()
enum.index = startIndex
enum.index = startIndex
enum.current = nil
local function iterator(t, k)
local function iterator(t, k)
if enum:moveNext() == true then
if enum:moveNext() == true then
Line 84: Line 89:


function TableEnumerator:getEnumerator()
function TableEnumerator:getEnumerator()
mw.log('getting enum')
if self.state == 0 then
if self.state == 0 then
mw.log('getting self')
return self
return self
else
else
2,875

edits