[added] set.clear which does what you'd expect

This commit is contained in:
Max Cahill 2021-05-04 10:38:07 +10:00
parent 97eac9c51a
commit c2a9d39bcf

11
set.lua
View File

@ -46,6 +46,17 @@ function set:remove(v)
return self return self
end end
--remove all elements from the set
function set:clear()
if table.clear then
table.clear(self._keyed)
table.clear(self._ordered)
else
self._keyed = {}
self._ordered = {}
end
end
--get the number of distinct values in the set --get the number of distinct values in the set
function set:size() function set:size()
return #self._ordered return #self._ordered