Package org.tinspin.index
Interface PointIndex<T>
-
- Type Parameters:
T- Type of the value associated with the point key.
- All Superinterfaces:
Index<T>
- All Known Implementing Classes:
CoverTree,KDTree,PHTreeP,PointArray,PointIndexWrapper,QuadTreeKD,QuadTreeKD0,QuadTreeKD2
public interface PointIndex<T> extends Index<T>
A common interface for spatial indexes (maps) that use points as keys. This interface is somewhat inconsistent because it suggests that implementations acrt as "maps" which means that a given keys can exist only once and is overwritten when a new entry with the same key is added.However, most implementations in this library (except for the PH-Tree) act as multimaps which means they allow multple entries with identical keys.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidinsert(double[] key, T value)Insert a point.QueryIterator<? extends PointEntry<T>>iterator()QueryIterator<PointEntry<T>>query(double[] min, double[] max)default PointEntryDist<T>query1NN(double[] center)Finds the nearest neighbor.TqueryExact(double[] point)Lookup an entry, using exact match.QueryIteratorKNN<PointEntryDist<T>>queryKNN(double[] center, int k)Finds the nearest neighbor.Tremove(double[] point)Remove a point entry.Tupdate(double[] oldPoint, double[] newPoint)Update the position of an entry.-
Methods inherited from interface org.tinspin.index.Index
clear, getDepth, getDims, getNodeCount, getStats, size, toStringTree
-
-
-
-
Method Detail
-
insert
void insert(double[] key, T value)Insert a point.- Parameters:
key- pointvalue- value
-
remove
T remove(double[] point)
Remove a point entry.- Parameters:
point- the point- Returns:
- the value of the entry or null if the entry was not found
-
update
T update(double[] oldPoint, double[] newPoint)
Update the position of an entry.- Parameters:
oldPoint- old positionnewPoint- new position- Returns:
- the value of the entry or null if the entry was not found
-
queryExact
T queryExact(double[] point)
Lookup an entry, using exact match.- Parameters:
point- the point- Returns:
- the value of the entry or null if the entry was not found
-
iterator
QueryIterator<? extends PointEntry<T>> iterator()
- Returns:
- An iterator over all entries.
-
query
QueryIterator<PointEntry<T>> query(double[] min, double[] max)
- Parameters:
min- Lower left corner of the query windowmax- Upper right corner of the query window- Returns:
- All points that lie inside the query rectangle.
-
query1NN
default PointEntryDist<T> query1NN(double[] center)
Finds the nearest neighbor. This uses euclidean distance. Other distance types can only be specified directly on the index implementations.- Parameters:
center- center point- Returns:
- the nearest neighbor
-
queryKNN
QueryIteratorKNN<PointEntryDist<T>> queryKNN(double[] center, int k)
Finds the nearest neighbor. This uses euclidean distance. Other distance types can only be specified directly on the index implementations.- Parameters:
center- center pointk- number of neighbors- Returns:
- list of nearest neighbors
-
-