org.castor.cache.hashbelt.container
Class MapContainer<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<K,V>
          extended by org.castor.cache.hashbelt.container.MapContainer<K,V>
Type Parameters:
K - the type of keys maintained by this cache
V - the type of cached values
All Implemented Interfaces:
Serializable, Cloneable, Map<K,V>, Container<K,V>

public final class MapContainer<K,V>
extends HashMap<K,V>
implements Container<K,V>

A very basic, HashMap-based implementation of the hashmap container strategy, using nothing more than a basic hashmap to store key/value pairs. This works well for lots of gets and a reasonably high volume of removes; if few removes are required, and iterators are important to your particluar use-case of the cache, it's better to use the FastIteratingContainer, which can handle iterating at a higher speed, still has a map for accessing hash values, but has a higher removal cost.

Since:
1.0
Version:
$Revision: 9040 $ $Date: 2011-08-16 08:26:59 +0200 (Di, 16 Aug 2011) $
Author:
Gregory Block, Ralf Joachim
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
MapContainer()
           
 
Method Summary
 long getTimestamp()
          Returns the timestamp of this container.
 Iterator<K> keyIterator()
          Returns an iterator over the keys contained in this container.
 void updateTimestamp()
          Set the timestamp of this container to System.currentTimeMillis().
 Iterator<V> valueIterator()
          Returns an iterator over the values contained in this container.
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 

Constructor Detail

MapContainer

public MapContainer()
Method Detail

updateTimestamp

public void updateTimestamp()
Set the timestamp of this container to System.currentTimeMillis().

Specified by:
updateTimestamp in interface Container<K,V>

getTimestamp

public long getTimestamp()
Returns the timestamp of this container.

Specified by:
getTimestamp in interface Container<K,V>
Returns:
The timestamp.

keyIterator

public Iterator<K> keyIterator()
Returns an iterator over the keys contained in this container. If the container is modified while an iteration is in progress, the results of the iteration is not affected and vice-versa.

Specified by:
keyIterator in interface Container<K,V>
Returns:
An iterator over the keys currently contained in the container.

valueIterator

public Iterator<V> valueIterator()
Returns an iterator over the values contained in this container. If the container is modified while an iteration is in progress, the results of the iteration is not affected and vice-versa.

Specified by:
valueIterator in interface Container<K,V>
Returns:
An iterator over the values currently contained in the container.


Copyright © 2012. All Rights Reserved.