equal
deleted
inserted
replaced
1239 |
1239 |
1240 self._head = head = _lrucachenode() |
1240 self._head = head = _lrucachenode() |
1241 head.prev = head |
1241 head.prev = head |
1242 head.next = head |
1242 head.next = head |
1243 self._size = 1 |
1243 self._size = 1 |
1244 self._capacity = max |
1244 self.capacity = max |
1245 |
1245 |
1246 def __len__(self): |
1246 def __len__(self): |
1247 return len(self._cache) |
1247 return len(self._cache) |
1248 |
1248 |
1249 def __contains__(self, k): |
1249 def __contains__(self, k): |
1267 if node is not None: |
1267 if node is not None: |
1268 node.value = v |
1268 node.value = v |
1269 self._movetohead(node) |
1269 self._movetohead(node) |
1270 return |
1270 return |
1271 |
1271 |
1272 if self._size < self._capacity: |
1272 if self._size < self.capacity: |
1273 node = self._addcapacity() |
1273 node = self._addcapacity() |
1274 else: |
1274 else: |
1275 # Grab the last/oldest item. |
1275 # Grab the last/oldest item. |
1276 node = self._head.prev |
1276 node = self._head.prev |
1277 |
1277 |
1310 n = n.next |
1310 n = n.next |
1311 |
1311 |
1312 self._cache.clear() |
1312 self._cache.clear() |
1313 |
1313 |
1314 def copy(self): |
1314 def copy(self): |
1315 result = lrucachedict(self._capacity) |
1315 result = lrucachedict(self.capacity) |
1316 |
1316 |
1317 # We copy entries by iterating in oldest-to-newest order so the copy |
1317 # We copy entries by iterating in oldest-to-newest order so the copy |
1318 # has the correct ordering. |
1318 # has the correct ordering. |
1319 |
1319 |
1320 # Find the first non-empty entry. |
1320 # Find the first non-empty entry. |