ucar.unidata.util
Class Pool<KeyType,ValueType>

java.lang.Object
  extended by ucar.unidata.util.Pool<KeyType,ValueType>
Type Parameters:
KeyType -
ValueType -

public class Pool<KeyType,ValueType>
extends Object

Provides a pool of keyed objects and keeps the total size below a given limit. This maps a key to a list of values. The get method is consumptive, it removes the returned value from the list. If the total number of list elements exceed the given cache size this will remove the elements from the list on a key based last used basis

Version:
$Revision: 1.271 $
Author:
IDV development group.

Constructor Summary
Pool(int size)
          ctor
 
Method Summary
 void clear()
          Clear the cache
 boolean contains(KeyType key)
          _more_
 boolean containsOrCreate(KeyType key)
          _more_
protected  ValueType createValue(KeyType key)
          _more_
 ValueType get(KeyType key)
          _more_
protected  ValueType getFromPool(List<ValueType> list)
          _more_
 Object getMutex()
          _more_
 int getSize()
          _more_
 void getStats(StringBuffer sb)
          _more_
 void put(KeyType key, ValueType value)
          _more_
protected  void removeValue(KeyType key, ValueType object)
          _more_
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Pool

public Pool(int size)
ctor

Parameters:
size - max size
Method Detail

getMutex

public Object getMutex()
_more_

Returns:
_more_

contains

public boolean contains(KeyType key)
_more_

Parameters:
key - _more_
Returns:
_more_

get

public ValueType get(KeyType key)
_more_

Parameters:
key - _more_
Returns:
_more_

getFromPool

protected ValueType getFromPool(List<ValueType> list)
_more_

Parameters:
list - _more_
Returns:
_more_

containsOrCreate

public boolean containsOrCreate(KeyType key)
_more_

Parameters:
key - _more_
Returns:
_more_

put

public void put(KeyType key,
                ValueType value)
_more_

Parameters:
key - _more_
value - _more_

getStats

public void getStats(StringBuffer sb)
_more_

Parameters:
sb - _more_

clear

public void clear()
Clear the cache


getSize

public int getSize()
_more_

Returns:
_more_

createValue

protected ValueType createValue(KeyType key)
_more_

Parameters:
key - _more_
Returns:
_more_

removeValue

protected void removeValue(KeyType key,
                           ValueType object)
_more_

Parameters:
key - _more_
object - _more_