util.set: Add set:empty() to discover if the set is the empty set

Wed, 22 Apr 2009 18:03:02 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Wed, 22 Apr 2009 18:03:02 +0100
changeset 1029
4ead03974759
parent 1028
594a07e753a0
child 1030
a82268d507fc

util.set: Add set:empty() to discover if the set is the empty set

util/set.lua file | annotate | diff | comparison | revisions
--- a/util/set.lua	Wed Apr 22 18:00:45 2009 +0100
+++ b/util/set.lua	Wed Apr 22 18:03:02 2009 +0100
@@ -91,6 +91,10 @@
 		end
 	end
 	
+	function set:empty()
+		return not next(items);
+	end
+	
 	if list then
 		set:add_list(list);
 	end

mercurial