util.cache: Add method for iterating over values
authorKim Alvefur <zash@zash.se>
Fri, 15 Apr 2016 13:19:20 +0200
changeset 7357 8ca7f1c2c660
parent 7354 11434c46b7b7
child 7358 4b4cf0167391
util.cache: Add method for iterating over values
util/cache.lua
--- a/util/cache.lua	Wed Apr 13 20:00:41 2016 +0200
+++ b/util/cache.lua	Fri Apr 15 13:19:20 2016 +0200
@@ -88,6 +88,18 @@
 	end
 end
 
+function cache_methods:values()
+	local m = self._head;
+	return function ()
+		if not m then
+			return;
+		end
+		local v = m.value;
+		m = m.next;
+		return v;
+	end
+end
+
 function cache_methods:count()
 	return self._count;
 end