palio.modules.cache
Class LRUList
java.lang.Object
palio.modules.cache.LRUList
public class LRUList
- extends java.lang.Object
Last recently used (LRU) list intended primarily to use in caches.
Of course you can use ordinary list for that purpose,
but removing objects will be O(n) instead of O(1).
The LRUList
defines Entry
inner class as
an object placeholder.
Entry
instances should be kept and modified,
you should not need to use
use entryForObject
method. In this case you will get
O(n) performance.
- Author:
- Wojciech Lewicki, Mateusz Gembarzewski
Nested Class Summary |
class |
LRUList.Entry
Element of the LRU list. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LRUList
public LRUList()
getFirst
public LRUList.Entry getFirst()
- Returns:
- First entry in the LRU list (or
null
if the list is empty).
getLast
public LRUList.Entry getLast()
- Returns:
- last entry in the LRU list (or
null
if the list is empty).
entryForObject
public LRUList.Entry entryForObject(java.lang.Object obj)
- Parameters:
obj
- Object
- Returns:
- Entry containing given object in O(n) time.
newEntry
public LRUList.Entry newEntry(java.lang.Object obj)
- Creates new entry in the LRU list. The new entry will be
inserted in the front of this list.
- Parameters:
obj
- Object
- Returns:
- Newly created entry.
clear
public void clear()