Module:FunList/Iterators: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 33: Line 33:
end
end


function Enumerator:getEnumerator(isArray)
function Enumerator:getEnumerator()
error('Not implemented in base class.')
error('Not implemented in base class.')
end
end
Line 40: Line 40:
function Enumerator:overridePairs(startIndex)
function Enumerator:overridePairs(startIndex)
-- Get or create clean enumerator. This ensures the state is 0.
-- Get or create clean enumerator. This ensures the state is 0.
local enum = self:getEnumerator(startIndex == 0)
local enum = self:getEnumerator()
enum.current = nil
enum.current = nil
enum.index = startIndex
enum.index = startIndex
enum.isArray = startIndex == 0
local function iterator(t, k)
local function iterator(t, k)
if enum:moveNext() == true then
if enum:moveNext() == true then
2,875

edits