edu.berkeley.nlp.lm.cache
Class ArrayEncodedDirectMappedLmCache

java.lang.Object
  extended by edu.berkeley.nlp.lm.cache.ArrayEncodedDirectMappedLmCache
All Implemented Interfaces:
ArrayEncodedLmCache, Serializable

public final class ArrayEncodedDirectMappedLmCache
extends Object
implements ArrayEncodedLmCache

A direct-mapped cache. This cache does not perform any collision resolution, but rather retains only the most recent key which gets hashed to a particular bucket.

Author:
adampauls
See Also:
Serialized Form

Constructor Summary
ArrayEncodedDirectMappedLmCache(int cacheBits, int maxNgramOrder, boolean threadSafe)
           
 
Method Summary
 int capacity()
          How n-grams can be cached (at most).
 void clear()
           
 float getCached(int[] ngram, int startPos, int endPos, int hash)
          Should return Float.NaN if the requested n-gram is not in the cache
 void putCached(int[] ngram, int startPos, int endPos, float f, int hash)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayEncodedDirectMappedLmCache

public ArrayEncodedDirectMappedLmCache(int cacheBits,
                                       int maxNgramOrder,
                                       boolean threadSafe)
Method Detail

getCached

public float getCached(int[] ngram,
                       int startPos,
                       int endPos,
                       int hash)
Description copied from interface: ArrayEncodedLmCache
Should return Float.NaN if the requested n-gram is not in the cache

Specified by:
getCached in interface ArrayEncodedLmCache
Returns:

clear

public void clear()
Specified by:
clear in interface ArrayEncodedLmCache

putCached

public void putCached(int[] ngram,
                      int startPos,
                      int endPos,
                      float f,
                      int hash)
Specified by:
putCached in interface ArrayEncodedLmCache

capacity

public int capacity()
Description copied from interface: ArrayEncodedLmCache
How n-grams can be cached (at most).

Specified by:
capacity in interface ArrayEncodedLmCache
Returns: