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) int
bad
Number of uncacheable queries(package private) it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap
cache
Cache(package private) DistanceQuery<V>
inner
Inner 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 void
clear()
Clear the distance cache.double
distance(DBIDRef id1, DBIDRef id2)
Returns the distance between the two objects specified by their object ids.double
distance(DBIDRef id1, V o2)
Returns the distance between the two objects specified by their object ids.double
distance(V o1, DBIDRef id2)
Returns the distance between the two objects specified by their object ids.double
distance(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.boolean
hasUncachedQueries()
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:DistanceQuery
Returns the distance between the two objects specified by their object ids.- Specified by:
distance
in 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:DistanceQuery
Returns the distance between the two objects specified by their object ids.- Specified by:
distance
in 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:DistanceQuery
Returns the distance between the two objects specified by their object ids.- Specified by:
distance
in 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:DistanceQuery
Returns the distance between the two objects specified by their object ids.- Specified by:
distance
in 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:DistanceQuery
Get the inner distance function.- Specified by:
getDistance
in interfaceDistanceQuery<V>
- Returns:
- Distance function
-
getRelation
public Relation<? extends V> getRelation()
Description copied from interface:DistanceQuery
Access the underlying data query.- Specified by:
getRelation
in interfaceDistanceQuery<V>
- Returns:
- data query in use
-
-