Home | Trees | Indices | Help |
---|
|
object --+ | dict --+ | LRUDict
LRUDict is a dictionary of a fixed maximum size that enforces a least recently used discard policy. When the dictionary is full (i.e., contains the maximum number of entries), any attempt to insert a new entry causes one of the least recently used entries to be discarded.
Note:
An LRUDict also supports the concept of removal listeners. Removal listeners are functions that are notified when objects are removed from the dictionary. Removal listeners can be:
This implementation is based on a Java LRUMap class in the org.clapper.util library. See http://software.clapper.org/java/util/ for details.
|
|||
new empty dictionary |
|
||
|
|||
int |
|
||
|
|||
|
|||
|
|||
bool |
|
||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
None |
|
||
D[k] if k in D, else d |
|
||
list of D's keys |
|
||
list of D's (key, value) pairs, as 2-tuples |
|
||
list of D's values |
|
||
an iterator over the (key, value) items of D |
|
||
an iterator over the keys of D |
|
||
an iterator over the values of D |
|
||
None |
|
||
v, remove specified key and return the corresponding value |
|
||
tuple |
|
||
|
|||
|
|||
|
|||
Inherited from Inherited from |
|
|||
Inherited from |
|
|||
max_capacity The maximum capacity. |
|||
Inherited from |
|
|
|
|
Add an ejection listener to the dictionary. The listener function should take at least two parameters: the key and value being removed. It can also take additional parameters, which are passed through unmodified. An ejection listener is only notified when objects are ejected from the cache to make room for new objects; more to the point, an ejection listener is never notified when an object is removed from the cache manually, via use of the del operator.
|
Add a removal listener to the dictionary. The listener function should take at least two parameters: the key and value being removed. It can also take additional parameters, which are passed through unmodified. A removal listener is notified when objects are ejected from the cache to make room for new objects and when objects are manually deleted from the cache.
|
|
x[i]=y
|
x[y]
|
del x[y]
|
str(x)
|
iter(x)
|
Remove all items from D.
|
d defaults to None.
|
|
|
|
|
|
|
Update D from dict/iterable E and F. If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
|
If key is not found, d is returned if given, otherwise KeyError is raised
|
|
|
max_capacityThe maximum capacity. Can be reset at will.
|
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Mon Mar 14 15:21:05 2016 | http://epydoc.sourceforge.net |