mirror of
https://github.com/bjc/prosody.git
synced 2025-04-03 21:27:38 +03:00
util.set: Add freeze metamethod
This commit is contained in:
parent
15ba5f41b1
commit
1ab9729aac
1 changed files with 8 additions and 0 deletions
|
@ -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 };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue