|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.onemind.commons.java.datastructure.MruList
public class MruList
Most recently used list implementation. It support entries expiration by access time.
Nested Class Summary | |
---|---|
protected static class |
MruList.MruEntry
Represent an entry in the MruList |
protected static class |
MruList.MruIterator
An iterator to the entries |
Field Summary | |
---|---|
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 Summary | |
---|---|
MruList()
|
|
MruList(long sizeLimit,
long timeout)
|
Method Summary | |
---|---|
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 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Set |
---|
equals, hashCode |
Field Detail |
---|
private java.util.HashMap _entryMap
private long _lastCleanupTime
private java.util.TreeSet _mruList
private long _sizeLimit
private long _timeout
Constructor Detail |
---|
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)Method Detail |
---|
public boolean access(java.lang.Object o)
o
- the object
public 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 object
public 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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |