|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractMap
wt.util.Cache
A fixed size, most recently used object cache.
The caches size is set at construction, and only the most recently used
entries are maintained. Each get or put operation makes that entry the
most recently used. When putting new entries, if the cache is full, the
least recently used entry is aged out of the cache.
Supported API: true
Extendable: false
Nested Class Summary | |
protected class |
Cache.CacheEntry
Default implementation of Map.Entry |
(package private) class |
Cache.EntrySet
Implements a modifiable set based on the entries in this cache |
(package private) class |
Cache.KeySet
|
Nested classes inherited from class java.util.AbstractMap |
|
Nested classes inherited from class java.util.Map |
Map.Entry |
Field Summary | |
protected int |
agedOut
|
protected int |
cacheSize
|
protected int |
count
|
(package private) Set |
entrySet
|
protected int[] |
hashCodes
|
protected int |
hits
|
protected Object[] |
keys
|
(package private) Set |
keySet
|
private int |
leastRecentlyUsed
|
protected int |
misses
|
protected int |
modCount
|
private int |
mostRecentlyUsed
|
private int[] |
newer
|
private int[] |
next
|
private int[] |
older
|
private int[] |
prev
|
private static String |
RESOURCE
|
protected int |
tableSize
|
protected Object[] |
values
|
Constructor Summary | |
Cache(int size)
Construct a new fixed-size, most-recently-used cache. |
|
Cache(Map m)
|
Method Summary | |
void |
clear()
Clears the cache. |
boolean |
containsKey(Object key)
Determines if this cache contains the given key |
boolean |
containsValue(Object value)
Determines if this cache contains the given value |
protected Map.Entry |
createEntry(int index)
Used to create the Map.Entry instances stored by this cache |
Enumeration |
entries()
Deprecated. Replaced by values().iterator()
Supported API: true |
Set |
entrySet()
|
protected int |
find(Object key)
Protected method that finds existing entry. |
Object |
get(Object key)
Get an entry from the cache. |
Object |
getAndRemove(Object key)
Deprecated. Replaced by remove(Object)
Supported API: true |
Object |
getAndReplace(Object key,
Object value)
Deprecated. Replaced by put(Object,Object)
Supported API: true |
Object[] |
getKeys()
Get an array of the keys in this Cache. |
Set |
keySet()
|
protected int |
link(Object key)
Protected method that finds slot for an existing or new entry. |
protected void |
overflow(Object key,
Object value)
Called when an entry is being aged out of the cache. |
protected void |
print()
|
Object |
put(Object key,
Object value)
Put an entry in the cache. |
Object |
remove(Object key)
Remove an entry from the cache. |
int |
size()
Get the number of mappings in this cache |
String |
toString()
Returns string representation of the cache. |
protected void |
touch(int index)
Protected method to update age links to make the given entry be the most recently used. |
private void |
unlink(int index)
Private method to unlink an entry from the cache. |
Methods inherited from class java.util.AbstractMap |
clone, equals, hashCode, isEmpty, putAll, values |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
private static final String RESOURCE
protected int cacheSize
protected int tableSize
protected int count
protected Object[] keys
protected Object[] values
protected int[] hashCodes
protected int hits
protected int misses
protected int agedOut
protected int modCount
private int mostRecentlyUsed
private int leastRecentlyUsed
private int[] newer
private int[] older
private int[] next
private int[] prev
transient Set entrySet
transient Set keySet
Constructor Detail |
public Cache(int size)
size
- the maximum number of entries stored in the cache.public Cache(Map m)
Method Detail |
public boolean containsKey(Object key)
key
-
public boolean containsValue(Object value)
value
-
public int size()
public Object get(Object key)
key
- the entry key
public Object put(Object key, Object value)
key
- the entry keyvalue
- the value to associate with the given key
public Object getAndReplace(Object key, Object value)
put(Object,Object)
key
- the entry keyvalue
- the value to associate with the given key
public Object remove(Object key)
key
- the entry keypublic Object getAndRemove(Object key)
remove(Object)
key
- the entry key
public void clear()
protected int find(Object key)
key
- the entry key
protected int link(Object key)
key
- the entry key
protected void touch(int index)
index
- the index of the entryprivate void unlink(int index)
index
- the index of the entrypublic Enumeration entries()
values().iterator()
Enumeration
of the values in the cache.
public String toString()
protected void overflow(Object key, Object value)
key
- the entry keyvalue
- the entry valueprotected void print()
public Object[] getKeys()
For a Collection-based view of the keys in this cache
public Set entrySet()
public Set keySet()
protected Map.Entry createEntry(int index)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |