Anonymous

Module:FunList: Difference between revisions

From Melvor Idle
no edit summary
No edit summary
No edit summary
Line 317: Line 317:
end
end


function funlist:toLookup()
function funlist:toLookup(keySelector, valueSelector)
assert(keySelector)
local lookup = {}
 
-- Filter out unique values.
for _, item in pairs(self.mytable) do
local key = keySelector(item)
local value = valueSelector and valueSelector(item) or item
if not lookup[key] then
hashSet[key] = {}
end
 
table.insert(lookup[key], item)
end
self.mytable = lookup
return self
end
end


2,875

edits