com.bigdata.cache
Interface IConcurrentWeakValueCache<K,V>

Type Parameters:
K -
V -
All Known Implementing Classes:
ConcurrentWeakValueCache, ConcurrentWeakValueCacheWithBatchedUpdates, ConcurrentWeakValueCacheWithTimeout, IndexCache

public interface IConcurrentWeakValueCache<K,V>

Version:
$Id: IConcurrentWeakValueCache.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson

Method Summary
 int capacity()
          The capacity of the backing hard reference queue.
 void clear()
          Clear all entries in the map.
 boolean containsKey(K k)
          Return true iff the map contains an entry for the key whose weak reference has not been cleared.
 Iterator<Map.Entry<K,WeakReference<V>>> entryIterator()
          An iterator that visits the entries in the map.
 V get(K k)
          Returns the value for the key.
 Iterator<WeakReference<V>> iterator()
          An iterator that visits the weak reference values in the map.
 V put(K k, V v)
          Adds the key-value mapping to the cache.
 V putIfAbsent(K k, V v)
          Adds the key-value mapping to the cache iff there is no entry for that key.
 V remove(K k)
          Remove the entry for the key.
 int size()
          Returns the approximate number of keys in the map.
 

Method Detail

size

int size()
Returns the approximate number of keys in the map. Cleared references are removed before reporting the size of the map, but the return value is still approximate as garbage collection by the JVM can cause references to be cleared at any time.


capacity

int capacity()
The capacity of the backing hard reference queue.


clear

void clear()
Clear all entries in the map.


get

V get(K k)
Returns the value for the key.

Parameters:
k - The key.
Returns:
The value.

containsKey

boolean containsKey(K k)
Return true iff the map contains an entry for the key whose weak reference has not been cleared.

Parameters:
k - The key.
Returns:
true iff the map contains an entry for that key whose weak reference has not been cleared.

put

V put(K k,
      V v)
Adds the key-value mapping to the cache.

Parameters:
k - The key.
v - The value.
Returns:
The old value under the key -or- null if there is no entry under the key or if the entry under the key has has its reference cleared.

putIfAbsent

V putIfAbsent(K k,
              V v)
Adds the key-value mapping to the cache iff there is no entry for that key. Note that a cleared reference under a key is treated in exactly the same manner as if there were no entry under the key (the entry under the key is replaced atomically).

Parameters:
k - The key.
v - The value.
Returns:
the previous value associated with the specified key, or null if there was no mapping for the key or if the entry under the key has has its reference cleared.

remove

V remove(K k)
Remove the entry for the key.

Parameters:
k - The key.
Returns:
The previous value associated with the key, or null if there was no mapping for the key or if the entry under the key has has its reference cleared.

iterator

Iterator<WeakReference<V>> iterator()
An iterator that visits the weak reference values in the map. You must test each weak reference in order to determine whether its value has been cleared as of the moment that you request that value.


entryIterator

Iterator<Map.Entry<K,WeakReference<V>>> entryIterator()
An iterator that visits the entries in the map. You must test the weak reference for each entry in order to determine whether its value has been cleared as of the moment that you request that value.



Copyright © 2006-2012 SYSTAP, LLC. All Rights Reserved.