-- Cached function decorators.-- lru-- lfu-- rr
local defaultsize = 128
-- An ordered dict implementation.local orderedDict =
function orderedDict.create(argDict, argOrder) if (#dict) ~= (#order) then return nil end -- grrr, this won't work if I want (amortized) O(1) removal -- TODO: Use a double-linked map of the form table
-- These need to go into the metatable. They interfere with indexing.function orderedDict:has(od, k) local dict, order, nils = getmetatable(od).__mwint__leak return (dict[k] ~= nil) or (nils[k])end
function orderedDict:pop(od, k) local dict, order, nils = getmetatable(od).__mwint__leak if orderedDict:has(od, k) then v = dict[k] table.remove(dict, k) if v
local function lru_cache(func, size) size = size or defaultsize memo = OrderedDict.create end
return