orchidmap-front/osrm/lib/set.lua
2018-08-27 15:51:26 +07:00

23 lines
No EOL
445 B
Lua

-- Set of items
-- Fast check for inclusion, but unordered.
--
-- Instead of having to do:
-- whitelist = { 'apple'=true, 'cherries'=true, 'melons'=true }
--
-- you can do:
-- whitelist = Set { 'apple', 'cherries', 'melons' }
--
-- and then use it as:
-- print( whitelist['cherries'] ) => true
function Set(source)
set = {}
if source then
for i,v in ipairs(source) do
set[v] = true
end
end
return set
end
return Set