absurdist
Class LinkSimCacheArray

java.lang.Object
  extended byabsurdist.LinkSimCacheArray
All Implemented Interfaces:
LinkSimCache

class LinkSimCacheArray
extends java.lang.Object
implements LinkSimCache

LinkSimCache implemented as a rectangular array. Only rows and columns representing actual non-empty links, plus the EMPTY constant, are stored; this is designed to save on the overhead, as compared to LinkSimCacheHash. Access may not be as fast as with LinkSimCacheHash, though.

See Also:
LinkSimCache, LinkSimCacheHash

Constructor Summary
(package private) LinkSimCacheArray()
           
 
Method Summary
 double get(Link lo, Link ln)
          Retrieves the value representing Sim(lo,ln), or NaN if none was stored)
 double put(Link lo, Link ln, double val)
          Stores the value representing Sim(lo,ln).
 void setSizes(int loCnt, int lnCnt)
          Allocates the arrays based on the sizes specified.
 int size()
          Returns the number of values stored
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinkSimCacheArray

LinkSimCacheArray()
Method Detail

setSizes

public void setSizes(int loCnt,
                     int lnCnt)
Allocates the arrays based on the sizes specified.

Specified by:
setSizes in interface LinkSimCache
Parameters:
loCnt - How many distinct values for the first argument to put() are expected.
lnCnt - How many distinct values for the second argument to put() are expected.

put

public double put(Link lo,
                  Link ln,
                  double val)
Stores the value representing Sim(lo,ln). Returns the value previously stored in the table (NaN if none was stored)

Specified by:
put in interface LinkSimCache

get

public double get(Link lo,
                  Link ln)
Retrieves the value representing Sim(lo,ln), or NaN if none was stored)

Specified by:
get in interface LinkSimCache

size

public int size()
Description copied from interface: LinkSimCache
Returns the number of values stored

Specified by:
size in interface LinkSimCache