public class MruList
extends java.lang.Object
implements java.util.Set
Modifier and Type | Class and Description |
---|---|
protected static class |
MruList.MruEntry
Represent an entry in the MruList
|
protected static class |
MruList.MruIterator
An iterator to the entries
|
Modifier and Type | Field and Description |
---|---|
private java.util.HashMap |
_entryMap
the entries map *
|
private long |
_lastCleanupTime
the last cleanup time *
|
private java.util.TreeSet |
_mruList
the sorted mru list *
|
private long |
_sizeLimit
the size *
|
private long |
_timeout
the timeout *
|
Constructor and Description |
---|
MruList() |
MruList(long sizeLimit,
long timeout) |
Modifier and Type | Method and Description |
---|---|
boolean |
access(java.lang.Object o)
Record that object o is being accessed.
|
boolean |
add(java.lang.Object o) |
boolean |
addAll(java.util.Collection c) |
void |
clear() |
boolean |
contains(java.lang.Object o) |
boolean |
containsAll(java.util.Collection c) |
void |
expireEntries(long t)
Expire the entries that was last access longer that time t Document this method.
|
protected void |
expireEntry(java.lang.Object obj)
Remove the entry from the MruList
|
long |
getLastAccessTime(java.lang.Object obj)
Get the last access time object obj
|
boolean |
isEmpty() |
java.util.Iterator |
iterator() |
boolean |
remove(java.lang.Object o) |
boolean |
removeAll(java.util.Collection c) |
boolean |
retainAll(java.util.Collection c) |
int |
size() |
java.lang.Object[] |
toArray() |
java.lang.Object[] |
toArray(java.lang.Object[] a) |
void |
truncateEntries(long size)
Truncate the entries to specific size
|
protected void |
truncateEntry(java.lang.Object obj)
Remove the object from the MruList
|
private java.util.HashMap _entryMap
private long _lastCleanupTime
private java.util.TreeSet _mruList
private long _sizeLimit
private long _timeout
public MruList()
public MruList(long sizeLimit, long timeout)
sizeLimit
- the size limit of the MruList (0 for no size limit)timeout
- the timeout (0 for never timeout)public boolean access(java.lang.Object o)
o
- the objectpublic boolean add(java.lang.Object o)
add
in interface java.util.Collection
add
in interface java.util.Set
access(Object o)
public boolean addAll(java.util.Collection c)
addAll
in interface java.util.Collection
addAll
in interface java.util.Set
public void clear()
clear
in interface java.util.Collection
clear
in interface java.util.Set
public boolean contains(java.lang.Object o)
contains
in interface java.util.Collection
contains
in interface java.util.Set
public boolean containsAll(java.util.Collection c)
containsAll
in interface java.util.Collection
containsAll
in interface java.util.Set
public void expireEntries(long t)
t
- the elapse timepublic long getLastAccessTime(java.lang.Object obj)
obj
- the objectpublic boolean isEmpty()
isEmpty
in interface java.util.Collection
isEmpty
in interface java.util.Set
public java.util.Iterator iterator()
iterator
in interface java.lang.Iterable
iterator
in interface java.util.Collection
iterator
in interface java.util.Set
public boolean remove(java.lang.Object o)
remove
in interface java.util.Collection
remove
in interface java.util.Set
public boolean removeAll(java.util.Collection c)
removeAll
in interface java.util.Collection
removeAll
in interface java.util.Set
public boolean retainAll(java.util.Collection c)
retainAll
in interface java.util.Collection
retainAll
in interface java.util.Set
public int size()
size
in interface java.util.Collection
size
in interface java.util.Set
public java.lang.Object[] toArray()
toArray
in interface java.util.Collection
toArray
in interface java.util.Set
public java.lang.Object[] toArray(java.lang.Object[] a)
toArray
in interface java.util.Collection
toArray
in interface java.util.Set
public void truncateEntries(long size)
size
- the sizeprotected void truncateEntry(java.lang.Object obj)
obj
- the objectprotected void expireEntry(java.lang.Object obj)
obj
- expire the entry