Comparison

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
comparison
equal deleted inserted replaced
9900:f2104b36f673 9901:c8b75239846c
62 read_pos = (read_pos%size); 62 read_pos = (read_pos%size);
63 end 63 end
64 return pos+1, t._items[read_pos]; 64 return pos+1, t._items[read_pos];
65 end, self, 0; 65 end, self, 0;
66 end; 66 end;
67 consume = function (self)
68 return self.pop, self;
69 end;
67 }; 70 };
68 end 71 end
69 72
70 return { 73 return {
71 new = new; 74 new = new;