de.lmu.ifi.dbs.elki.database
Class DistanceCache<D extends Distance<D>>
java.lang.Object
de.lmu.ifi.dbs.elki.database.DistanceCache<D>
public class DistanceCache<D extends Distance<D>>
- extends Object
Provides a cache for distances between database objects.
- Author:
- Elke Achtert
Method Summary |
boolean |
containsKey(Integer id1,
Integer id2)
Returns true if this cache contains a distance value for the specified
ids. |
D |
get(Integer id1,
Integer id2)
Returns the distance value of the specified ids if it has been cached, null otherwise. |
void |
put(Integer id1,
Integer id2,
D distance)
Puts the specified distance value for the given ids to cache. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
cache
private Map<Integer,Map<Integer,D extends Distance<D>>> cache
- The map holding the pairwise distances.
DistanceCache
public DistanceCache()
put
public void put(Integer id1,
Integer id2,
D distance)
- Puts the specified distance value for the given ids to cache.
- Parameters:
id1
- the first idid2
- the second iddistance
- the distance value
get
public D get(Integer id1,
Integer id2)
- Returns the distance value of the specified ids if it has been cached, null otherwise.
- Parameters:
id1
- the first idid2
- the second id
- Returns:
- the distance value of the specified ids if it has been cached, null otherwise
containsKey
public boolean containsKey(Integer id1,
Integer id2)
- Returns true if this cache contains a distance value for the specified
ids.
- Parameters:
id1
- the first idid2
- the second id
- Returns:
- true if this cache contains a distance value for the specified
ids, false otherwise