Diff

util/queue.lua @ 9901:c8b75239846c

util.queue: Add 'consume()' convenience iterator
author Matthew Wild <mwild1@gmail.com>
date Sat, 23 Mar 2019 08:47:55 +0000
parent 6912:cb5b14c95b7b
child 9902:3eea63a68e0f
line wrap: on
line diff
--- a/util/queue.lua	Sat Mar 23 04:00:55 2019 +0100
+++ b/util/queue.lua	Sat Mar 23 08:47:55 2019 +0000
@@ -64,6 +64,9 @@
 				return pos+1, t._items[read_pos];
 			end, self, 0;
 		end;
+		consume = function (self)
+			return self.pop, self;
+		end;
 	};
 end