mirror of
https://github.com/1bardesign/batteries.git
synced 2024-11-22 14:14:36 +00:00
[added] set.clear
which does what you'd expect
This commit is contained in:
parent
97eac9c51a
commit
c2a9d39bcf
11
set.lua
11
set.lua
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user