aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-03-22 12:37:56 +0000
committerMatthew Wild <mwild1@gmail.com>2009-03-22 12:37:56 +0000
commit0cb055053f07c6f16e0980df910460ea9548f5ca (patch)
tree3fcaa2d669c56e640a9940dc08290e939d5e2444 /util
parent7f87706ee40a05db4e8572313d68ca8911f1415a (diff)
downloadprosody-0cb055053f07c6f16e0980df910460ea9548f5ca.tar.gz
prosody-0cb055053f07c6f16e0980df910460ea9548f5ca.zip
util.set: Fix to make constructor work, and functions defined correctly
Diffstat (limited to 'util')
-rw-r--r--util/set.lua22
1 files changed, 14 insertions, 8 deletions
diff --git a/util/set.lua b/util/set.lua
index 08361d03..67f3dcaa 100644
--- a/util/set.lua
+++ b/util/set.lua
@@ -1,3 +1,5 @@
+local ipairs, pairs =
+ ipairs, pairs;
module "set"
@@ -5,40 +7,44 @@ function new(list)
local items = {};
local set = { items = items };
- function set:add(set, item)
+ function set:add(item)
items[item] = true;
end
- function set:contains(set, item)
- return items[item]
+ function set:contains(item)
+ return items[item];
end
- function set:items(set)
+ function set:items()
return items;
end
- function set:remove(set, item)
+ function set:remove(item)
items[item] = nil;
end
- function set:add_list(set, list)
+ function set:add_list(list)
for _, item in ipairs(list) do
items[item] = true;
end
end
- function set:include(set, otherset)
+ function set:include(otherset)
for item in pairs(otherset) do
items[item] = true;
end
end
- function set:exclude(set, otherset)
+ function set:exclude(otherset)
for item in pairs(otherset) do
items[item] = nil;
end
end
+ if list then
+ set:add_list(list);
+ end
+
return set;
end