aboutsummaryrefslogtreecommitdiff
path: root/test/unit/set.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit/set.lua')
-rw-r--r--test/unit/set.lua16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/unit/set.lua b/test/unit/set.lua
index 4e66546f32..f3d68c3042 100644
--- a/test/unit/set.lua
+++ b/test/unit/set.lua
@@ -26,6 +26,22 @@ function Set:new(items)
return obj
end
+function Set:copy()
+ local obj = {}
+ obj.nelem = self.nelem
+ obj.tbl = {}
+ obj.items = {}
+ for k, v in pairs(self.tbl) do
+ obj.tbl[k] = v
+ end
+ for k, v in pairs(self.items) do
+ obj.items[k] = v
+ end
+ setmetatable(obj, Set)
+ obj.__index = Set
+ return obj
+end
+
-- adds the argument Set to this Set
function Set:union(other)
for e in other:iterator() do