Changeset

7354:8ca7f1c2c660

util.cache: Add method for iterating over values
author Kim Alvefur <zash@zash.se>
date Fri, 15 Apr 2016 13:19:20 +0200
parents 7351:11434c46b7b7
children 7355:4b4cf0167391
files util/cache.lua
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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