| java.lang.Object org.mmbase.util.LRUHashtable
LRUHashtable | public class LRUHashtable implements Cloneable,CacheImplementationInterface<K, V>,SizeMeasurable(Code) | | A hashtable which has a maximum of entries. Old entries are
removed when the maximum is reached. This table is used mostly to
implement a simple caching system.
author: Rico Jansen author: Michiel Meeuwissen version: $Id: LRUHashtable.java,v 1.30 2007/08/01 06:44:43 michiel Exp $ See Also: org.mmbase.cache.Cache |
Inner Class :protected class LRUEntrySet extends AbstractSet> | |
Inner Class :protected class LRUEntrySetIterator implements Iterator<Map.Entry<K, V>> | |
Inner Class :protected class LRUValues extends AbstractCollection | |
Constructor Summary | |
public | LRUHashtable(int size, int cap, float lf) Creates the URL Hashtable. | public | LRUHashtable(int size, int cap) Creates the URL Hashtable with growing capacity 0.75. | public | LRUHashtable(int size) Creates the URL Hashtable with starting capacity 101 and
growing capacity 0.75. | public | LRUHashtable() Creates the URL Hashtable with maximum capacity 100,
starting capacity 101, and growing capacity 0.75. |
Method Summary | |
public synchronized void | clear() Clears the table. | public synchronized Object | clone() | public void | config(Map<String, String> map) | public boolean | containsKey(Object o) | public boolean | containsValue(Object o) | public synchronized Enumeration<V> | elements() Returns an Enumeration on the table's element values. | public Set<Map.Entry<K, V>> | entrySet() Returns the entries of this Map. | public synchronized V | get(Object key) Retrieves an element from the table. | public int | getByteSize() | public int | getByteSize(SizeOf sizeof) | public int | getCount(Object key) Retrieves the count of the object with a certain key. | public Enumeration<V> | getOrderedElements() | public Enumeration<V> | getOrderedElements(int maxnumber) | public List<? extends Map.Entry<K, V>> | getOrderedEntries() Returns an ordered list of Map.Entry's. | public List<? extends Map.Entry<K, V>> | getOrderedEntries(int maxNumber) Returns an ordered list of Map.Entry's. | public boolean | isEmpty() | public Set<K> | keySet() You should only remove entries from LRUHashtable using the 'remove' function, or using the
iterator of entrySet() otherwise the linked list gets messed up. | public int | maxSize() | public synchronized V | put(K key, V value) Store an element in the table. | public void | putAll(Map<? extends K, ? extends V> t) | public synchronized V | remove(Object key) Remove an element from the table. | public void | setMaxSize(int size) Change the maximum size of the table. | public int | size() | public String | toString() Returns a description of the table. | public String | toString(boolean which) Returns a description of the table.
The information shown includes current size, maximum size, ratio of misses and hits,
and either a description of the underlying hashtable, or a list of all stored values.
Parameters: which - if true , the stored values are described. | public Collection<V> | values() |
LRUHashtable | public LRUHashtable(int size, int cap, float lf)(Code) | | Creates the URL Hashtable.
Parameters: size - the maximum capacity Parameters: cap - the starting capacity (used to improve performance) Parameters: lf - the amount with which current capacity frows |
LRUHashtable | public LRUHashtable(int size, int cap)(Code) | | Creates the URL Hashtable with growing capacity 0.75.
Parameters: size - the maximum capacity Parameters: cap - the starting capacity (used to improve performance) |
LRUHashtable | public LRUHashtable(int size)(Code) | | Creates the URL Hashtable with starting capacity 101 and
growing capacity 0.75.
Parameters: size - the maximum capacity |
LRUHashtable | public LRUHashtable()(Code) | | Creates the URL Hashtable with maximum capacity 100,
starting capacity 101, and growing capacity 0.75.
|
clear | public synchronized void clear()(Code) | | Clears the table.
|
clone | public synchronized Object clone()(Code) | | NOT IMPLEMENTED
|
elements | public synchronized Enumeration<V> elements()(Code) | | Returns an Enumeration on the table's element values.
|
entrySet | public Set<Map.Entry<K, V>> entrySet()(Code) | | Returns the entries of this Map. Modification are reflected.
since: MMBase-1.6.3 |
get | public synchronized V get(Object key)(Code) | | Retrieves an element from the table.
Parameters: key - the key of the element the value of the element, or null if it could not be found |
getByteSize | public int getByteSize()(Code) | | |
getCount | public int getCount(Object key)(Code) | | Retrieves the count of the object with a certain key.
Parameters: key - the key of the element the times the key has been requested |
getOrderedEntries | public List<? extends Map.Entry<K, V>> getOrderedEntries()(Code) | | Returns an ordered list of Map.Entry's.
since: MMBase-1.6 |
getOrderedEntries | public List<? extends Map.Entry<K, V>> getOrderedEntries(int maxNumber)(Code) | | Returns an ordered list of Map.Entry's. This can be used to
present the contents of the LRU Map.
since: MMBase-1.6 |
isEmpty | public boolean isEmpty()(Code) | | |
keySet | public Set<K> keySet()(Code) | | You should only remove entries from LRUHashtable using the 'remove' function, or using the
iterator of entrySet() otherwise the linked list gets messed up. The keySet of LRUHashtable
therefore returns an unmodifiable set.
since: MMBase-1.6.3 |
maxSize | public int maxSize()(Code) | | Return the maximum size of the table
|
put | public synchronized V put(K key, V value)(Code) | | Store an element in the table.
Parameters: key - the key of the element Parameters: value - the value of the element the original value of the element if it existed, null if it could not be found |
putAll | public void putAll(Map<? extends K, ? extends V> t)(Code) | | |
remove | public synchronized V remove(Object key)(Code) | | Remove an element from the table.
Parameters: key - the key of the element the original value of the element if it existed, null if it could not be found |
setMaxSize | public void setMaxSize(int size)(Code) | | Change the maximum size of the table.
This may result in removal of entries in the table.
Parameters: size - the new desired size |
size | public int size()(Code) | | Return the current size of the table
|
toString | public String toString()(Code) | | Returns a description of the table.
The information shown includes current size, maximum size, ratio of misses and hits,
and a description of the underlying hashtable
|
toString | public String toString(boolean which)(Code) | | Returns a description of the table.
The information shown includes current size, maximum size, ratio of misses and hits,
and either a description of the underlying hashtable, or a list of all stored values.
Parameters: which - if true , the stored values are described. a description of the table. |
|
|