Package elki.clustering.kmedoids
Class CLARA.CachedDistanceQuery<V>
- java.lang.Object
-
- elki.clustering.kmedoids.CLARA.CachedDistanceQuery<V>
-
- Type Parameters:
V- Data type
- All Implemented Interfaces:
DistanceQuery<V>
protected static class CLARA.CachedDistanceQuery<V> extends java.lang.Object implements DistanceQuery<V>
Cached distance query.- Author:
- Erich Schubert
-
-
Field Summary
Fields Modifier and Type Field Description (package private) intbadNumber of uncacheable queries(package private) it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMapcacheCache(package private) DistanceQuery<V>innerInner distance query
-
Constructor Summary
Constructors Constructor Description CachedDistanceQuery(DistanceQuery<V> inner, int size)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clear the distance cache.doubledistance(DBIDRef id1, DBIDRef id2)Returns the distance between the two objects specified by their object ids.doubledistance(DBIDRef id1, V o2)Returns the distance between the two objects specified by their object ids.doubledistance(V o1, DBIDRef id2)Returns the distance between the two objects specified by their object ids.doubledistance(V o1, V o2)Returns the distance between the two objects specified by their object ids.Distance<? super V>getDistance()Get the inner distance function.Relation<? extends V>getRelation()Access the underlying data query.booleanhasUncachedQueries()Check if any queries were uncached (not using DBIDs).
-
-
-
Field Detail
-
inner
DistanceQuery<V> inner
Inner distance query
-
cache
it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap cache
Cache
-
bad
int bad
Number of uncacheable queries
-
-
Constructor Detail
-
CachedDistanceQuery
public CachedDistanceQuery(DistanceQuery<V> inner, int size)
Constructor.- Parameters:
inner- Inner querysize- Initial size of map
-
-
Method Detail
-
hasUncachedQueries
public boolean hasUncachedQueries()
Check if any queries were uncached (not using DBIDs).- Returns:
- True if uncached distances were used
-
clear
public void clear()
Clear the distance cache.
-
distance
public double distance(DBIDRef id1, DBIDRef id2)
Description copied from interface:DistanceQueryReturns the distance between the two objects specified by their object ids.- Specified by:
distancein interfaceDistanceQuery<V>- Parameters:
id1- first object idid2- second object id- Returns:
- the distance between the two objects specified by their object ids
-
distance
public double distance(V o1, DBIDRef id2)
Description copied from interface:DistanceQueryReturns the distance between the two objects specified by their object ids.- Specified by:
distancein interfaceDistanceQuery<V>- Parameters:
o1- first objectid2- second object id- Returns:
- the distance between the two objects specified by their object ids
-
distance
public double distance(DBIDRef id1, V o2)
Description copied from interface:DistanceQueryReturns the distance between the two objects specified by their object ids.- Specified by:
distancein interfaceDistanceQuery<V>- Parameters:
id1- first object ido2- second object- Returns:
- the distance between the two objects specified by their object ids
-
distance
public double distance(V o1, V o2)
Description copied from interface:DistanceQueryReturns the distance between the two objects specified by their object ids.- Specified by:
distancein interfaceDistanceQuery<V>- Parameters:
o1- first objecto2- second object- Returns:
- the distance between the two objects specified by their object ids
-
getDistance
public Distance<? super V> getDistance()
Description copied from interface:DistanceQueryGet the inner distance function.- Specified by:
getDistancein interfaceDistanceQuery<V>- Returns:
- Distance function
-
getRelation
public Relation<? extends V> getRelation()
Description copied from interface:DistanceQueryAccess the underlying data query.- Specified by:
getRelationin interfaceDistanceQuery<V>- Returns:
- data query in use
-
-