SableJBDD.cache
Class MultiWayCache

java.lang.Object
  extended bySableJBDD.cache.CacheProfiler
      extended bySableJBDD.cache.MultiWayCache
All Implemented Interfaces:
Profiling, TripleIntKeyCache

public class MultiWayCache
extends CacheProfiler
implements TripleIntKeyCache


Field Summary
 
Fields inherited from interface SableJBDD.bdd.util.Profiling
PROFILING
 
Constructor Summary
MultiWayCache(int capacity, int associativity)
          Defines a multi-way cache with a specific number of entries and an associativity.
 
Method Summary
 int getAssociativity()
           
 void invalidate(int key0, int key1, int key2)
          Removes an entry which matches the key.
 java.lang.Object lookup(int key0, int key1, int key2)
          Looks up the value associated with a key.
 int numberOfEntries()
           
 void put(int key0, int key1, int key2, java.lang.Object value)
          Puts a (key, value) entry into the cache.
 void reset()
          Resets cache entries.
 
Methods inherited from class SableJBDD.cache.CacheProfiler
accesses, hitRate, hits, misses, missRate, reportStatistics, steps
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface SableJBDD.bdd.util.Profiling
reportStatistics
 

Constructor Detail

MultiWayCache

public MultiWayCache(int capacity,
                     int associativity)
Defines a multi-way cache with a specific number of entries and an associativity.

Method Detail

lookup

public java.lang.Object lookup(int key0,
                               int key1,
                               int key2)
Looks up the value associated with a key.

Specified by:
lookup in interface TripleIntKeyCache
Parameters:
key0 - the 1st key
key1 - the 2nd key
key2 - the 3rd key
Returns:
the value object associated with the key

put

public void put(int key0,
                int key1,
                int key2,
                java.lang.Object value)
Puts a (key, value) entry into the cache. It is the caller's reponsibility to ensure the key does not exist in the cache (by a lookup first). The cache policy uses FIFO. It searches for an empty slot first. If no empty slot left, it removes the last one and shifts one entry to the end, and creates the new entry at the beginning.

Specified by:
put in interface TripleIntKeyCache
Parameters:
key0 - the 1st key
key1 - the 2nd key
key2 - the 3rd key
value - the cache value

reset

public void reset()
Resets cache entries.

Specified by:
reset in interface TripleIntKeyCache

invalidate

public void invalidate(int key0,
                       int key1,
                       int key2)
Removes an entry which matches the key.

Specified by:
invalidate in interface TripleIntKeyCache
Parameters:
key0 - the 1st key
key1 - the 2nd key
key2 - the 3rd key

numberOfEntries

public int numberOfEntries()
Specified by:
numberOfEntries in interface TripleIntKeyCache
Returns:
the number of cache entries.

getAssociativity

public int getAssociativity()
Specified by:
getAssociativity in interface TripleIntKeyCache
Returns:
the cache associativity