stamp.util
Class Cache

java.lang.Object
  |
  +--stamp.util.List
        |
        +--stamp.util.Pool
              |
              +--stamp.util.Cache

public class Cache
extends Pool

A cache is a special type of pool. When an attempt is made to check out a new object when all objects are in use, the 'oldest' object is returned.

A least recently used algorithm is used to determine the oldest object.

Caution: the LRU algorithm doesn't wrap around correctly.


Field Summary
protected  int[] age
           
protected  int globalAge
           
 
Fields inherited from class stamp.util.Pool
objectUsed
 
Fields inherited from class stamp.util.List
list, numObjects
 
Constructor Summary
Cache(int maxSize)
          Creates a new cache with the specified number of entries.
 
Method Summary
 Object checkOut()
          Check an object out of the pool.
 
Methods inherited from class stamp.util.Pool
checkIn
 
Methods inherited from class stamp.util.List
add, add, get, size
 
Methods inherited from class java.lang.Object
equals
 

Field Detail

age

protected int[] age

globalAge

protected int globalAge
Constructor Detail

Cache

public Cache(int maxSize)
Creates a new cache with the specified number of entries.
Method Detail

checkOut

public Object checkOut()
                throws IndexOutOfBoundsException
Check an object out of the pool.
Overrides:
checkOut in class Pool
Returns:
a free object instantance