oemware.core.util
Class LruMap<K,V>

java.lang.Object
  extended by oemware.core.util.LruMap<K,V>
All Implemented Interfaces:
java.util.Map<K,V>

public class LruMap<K,V>
extends java.lang.Object
implements java.util.Map<K,V>

An lru linked hash map. Access to this map is thread-safe. This class also supports an optional eviction handler. To handle old data that is removed from the map.


Nested Class Summary
static interface LruMap.EvictionHandler<K,V>
          The eviction handler interface.
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
LruMap(int pSize)
          Create a new lru map.
LruMap(int pSize, LruMap.EvictionHandler<K,V> pHandler)
          Create a new lru linked hash map.
 
Method Summary
 void clear()
           
 boolean containsKey(java.lang.Object pKey)
           
 boolean containsValue(java.lang.Object pValue)
           
 java.util.Set<java.util.Map.Entry<K,V>> entrySet()
           
 boolean equals(java.lang.Object pValue)
           
 V get(java.lang.Object pKey)
           
 int hashCode()
           
 boolean isEmpty()
           
 java.util.Set<K> keySet()
           
 V put(K pKey, V pValue)
           
 void putAll(java.util.Map<? extends K,? extends V> pValues)
           
 V remove(java.lang.Object pKey)
           
 int size()
           
 java.util.Collection<V> values()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LruMap

public LruMap(int pSize)
Create a new lru map.

Parameters:
pSize - The max size of the map.

LruMap

public LruMap(int pSize,
              LruMap.EvictionHandler<K,V> pHandler)
Create a new lru linked hash map.

Parameters:
pSize - The max size of the map.
pHandler - The optional eviction handler.
Method Detail

clear

public final void clear()
Specified by:
clear in interface java.util.Map<K,V>

size

public final int size()
Specified by:
size in interface java.util.Map<K,V>

values

public final java.util.Collection<V> values()
Specified by:
values in interface java.util.Map<K,V>

hashCode

public final int hashCode()
Specified by:
hashCode in interface java.util.Map<K,V>
Overrides:
hashCode in class java.lang.Object

get

public final V get(java.lang.Object pKey)
Specified by:
get in interface java.util.Map<K,V>

containsKey

public final boolean containsKey(java.lang.Object pKey)
Specified by:
containsKey in interface java.util.Map<K,V>

containsValue

public final boolean containsValue(java.lang.Object pValue)
Specified by:
containsValue in interface java.util.Map<K,V>

entrySet

public final java.util.Set<java.util.Map.Entry<K,V>> entrySet()
Specified by:
entrySet in interface java.util.Map<K,V>

isEmpty

public final boolean isEmpty()
Specified by:
isEmpty in interface java.util.Map<K,V>

keySet

public final java.util.Set<K> keySet()
Specified by:
keySet in interface java.util.Map<K,V>

put

public final V put(K pKey,
                   V pValue)
Specified by:
put in interface java.util.Map<K,V>

remove

public final V remove(java.lang.Object pKey)
Specified by:
remove in interface java.util.Map<K,V>

putAll

public final void putAll(java.util.Map<? extends K,? extends V> pValues)
Specified by:
putAll in interface java.util.Map<K,V>

equals

public final boolean equals(java.lang.Object pValue)
Specified by:
equals in interface java.util.Map<K,V>
Overrides:
equals in class java.lang.Object


Copyright © 2009 Deft Labs - Released under LGPL, Version 3.0