Comparison

util/queue.lua @ 11200:bf8f2da84007

Merge 0.11->trunk
author Kim Alvefur <zash@zash.se>
date Thu, 05 Nov 2020 22:31:25 +0100
parent 11114:6a608ecb3471
child 12975:d10957394a3c
comparison
equal deleted inserted replaced
11199:6c7c50a4de32 11200:bf8f2da84007
57 end 57 end
58 t[tail] = data; 58 t[tail] = data;
59 return true; 59 return true;
60 end; 60 end;
61 items = function (self) 61 items = function (self)
62 --luacheck: ignore 431/t 62 return function (_, pos)
63 return function (t, pos) 63 if pos >= items then
64 if pos >= t:count() then
65 return nil; 64 return nil;
66 end 65 end
67 local read_pos = tail + pos; 66 local read_pos = tail + pos;
68 if read_pos > t.size then 67 if read_pos > self.size then
69 read_pos = (read_pos%size); 68 read_pos = (read_pos%size);
70 end 69 end
71 return pos+1, t._items[read_pos]; 70 return pos+1, t[read_pos];
72 end, self, 0; 71 end, self, 0;
72 end;
73 consume = function (self)
74 return self.pop, self;
73 end; 75 end;
74 }; 76 };
75 end 77 end
76 78
77 return { 79 return {