aboutsummaryrefslogtreecommitdiffstats
path: root/util/set.lua
diff options
context:
space:
mode:
Diffstat (limited to 'util/set.lua')
-rw-r--r--util/set.lua8
1 files changed, 8 insertions, 0 deletions
diff --git a/util/set.lua b/util/set.lua
index a4f20138..02fabc6a 100644
--- a/util/set.lua
+++ b/util/set.lua
@@ -23,6 +23,14 @@ function items_mt.__call(items, _, k)
return next(items, k);
end
+function set_mt:__freeze()
+ local a, i = {}, 1;
+ for item in self._items do
+ a[i], i = item, i+1;
+ end
+ return a;
+end
+
local function new(list)
local items = setmetatable({}, items_mt);
local set = { _items = items };