X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=util%2Fset.lua;h=ee154ece11e1f5977be607735fa197acf10de4e4;hb=4643eae0bf41b461c9337bfb66f9ac80f7e84f11;hp=892f1c9d3f70e14bc75a3d36df9ebdcd98531078;hpb=e5d38fe21c831c19260459efa36c33e793c57cb6;p=prosody.git diff --git a/util/set.lua b/util/set.lua index 892f1c9d..ee154ece 100644 --- a/util/set.lua +++ b/util/set.lua @@ -1,3 +1,11 @@ +-- Prosody IM +-- Copyright (C) 2008-2010 Matthew Wild +-- Copyright (C) 2008-2010 Waqas Hussain +-- +-- This project is MIT/X11 licensed. Please see the +-- COPYING file in the source package for more information. +-- + local ipairs, pairs, setmetatable, next, tostring = ipairs, pairs, setmetatable, next, tostring; local t_concat = table.concat; @@ -91,6 +99,10 @@ function new(list) end end + function set:empty() + return not next(items); + end + if list then set:add_list(list); end @@ -137,4 +149,8 @@ function intersection(set1, set2) return set; end +function xor(set1, set2) + return union(set1, set2) - intersection(set1, set2); +end + return _M;