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 44: Line 39:
-- Get or create clean enumerator
-- Get or create clean enumerator
local enum = self:getEnumerator()
local enum = self:getEnumerator()
enum:reset()
enum.current = nil
enum.index = startIndex
enum.index = startIndex
local function iterator(t, k)
local function iterator(t, k)
Line 53: Line 48:
end
end
return iterator, enum, startIndex
return iterator, enum, enum.index
end
end


Line 70: Line 65:


function TableEnumerator:moveNext()
function TableEnumerator:moveNext()
mw.log('moving next')
if self.state == 0 then
if self.state == 0 then
self.state = 1
self.state = 1
2,875

edits