fix iter.next ?

This commit is contained in:
BreakWa11
2016-02-17 21:17:38 +08:00
parent 16eb3e3448
commit 41e92e277e
+4 -2
View File
@@ -82,7 +82,8 @@ class LRUCache(collections.MutableMapping):
def first(self):
if len(self._keys_to_last_time) > 0:
return iter(self._keys_to_last_time).next()
for key in self._keys_to_last_time:
return key
def sweep(self):
# O(n - m)
@@ -91,7 +92,8 @@ class LRUCache(collections.MutableMapping):
while c < SWEEP_MAX_ITEMS:
if len(self._keys_to_last_time) == 0:
break
key = iter(self._keys_to_last_time).next()
for key in self._keys_to_last_time:
break
last_t = self._keys_to_last_time[key]
if now - last_t <= self.timeout:
break