Software /
code /
prosody
Comparison
util/cache.lua @ 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 |
parent | 7290:70ab13e81cf5 |
child | 7435:8603b16e85c7 |
comparison
equal
deleted
inserted
replaced
7351:11434c46b7b7 | 7354:8ca7f1c2c660 |
---|---|
86 m = m.next; | 86 m = m.next; |
87 return k, v; | 87 return k, v; |
88 end | 88 end |
89 end | 89 end |
90 | 90 |
91 function cache_methods:values() | |
92 local m = self._head; | |
93 return function () | |
94 if not m then | |
95 return; | |
96 end | |
97 local v = m.value; | |
98 m = m.next; | |
99 return v; | |
100 end | |
101 end | |
102 | |
91 function cache_methods:count() | 103 function cache_methods:count() |
92 return self._count; | 104 return self._count; |
93 end | 105 end |
94 | 106 |
95 function cache_methods:head() | 107 function cache_methods:head() |