JXTA

net.jxta.impl.util
Class LRUCache<K,V>

java.lang.Object
  extended by net.jxta.impl.util.LRUCache<K,V>

public class LRUCache<K,V>
extends Object

This class implements a Generic LRU Cache. The cache is not thread-safe.

Author:
Ignacio J. Ortega, Mohamed Abdelaziz

Nested Class Summary
protected  class LRUCache.CacheNode<K,V>
          cache node object wrapper
 
Constructor Summary
LRUCache(int size)
          Constructor for the LRUCache object
 
Method Summary
 void clear()
          clear the cache
 boolean contains(K key)
           
 V get(K key)
          retrieve an object from cache
protected  Iterator<V> iterator(int size)
           
 void put(K key, V value)
          puts an object into cache
 V remove(K key)
          remove an object from cache
 int size()
          returns the number of elements currently in cache
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LRUCache

public LRUCache(int size)
Constructor for the LRUCache object

Parameters:
size - Description of the Parameter
Method Detail

clear

public void clear()
clear the cache


size

public int size()
returns the number of elements currently in cache

Returns:
the number of elements in cache

get

public V get(K key)
retrieve an object from cache

Parameters:
key - key
Returns:
object

contains

public boolean contains(K key)

iterator

protected Iterator<V> iterator(int size)

put

public void put(K key,
                V value)
puts an object into cache

Parameters:
key - key to store value by
value - object to insert

remove

public V remove(K key)
remove an object from cache

Parameters:
key - key
Returns:
Object removed

JXSE