Package org.tinspin.index.phtree
Class PHTreeMMP<T>
- java.lang.Object
-
- org.tinspin.index.phtree.PHTreeMMP<T>
-
- Type Parameters:
T- The value type associated with each entry.
- All Implemented Interfaces:
Index<T>,PointIndexMM<T>
public class PHTreeMMP<T> extends Object implements PointIndexMM<T>
Multimap version of the PH-Tree.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clear all entries.booleancontains(double[] point, T value)Lookup an entry, using exact match.static <T> PHTreeMMP<T>create(int dims)intgetDepth()intgetDims()intgetNodeCount()StatsgetStats()voidinsert(double[] key, T value)Insert a point.QueryIterator<PointEntry<T>>iterator()QueryIterator<PointEntry<T>>query(double[] key)Lookup an entries at a given coordinate.QueryIterator<PointEntry<T>>query(double[] min, double[] max)QueryIteratorKNN<PointEntryDist<T>>queryKNN(double[] center, int k)Finds the nearest neighbor.QueryIteratorKNN<PointEntryDist<T>>queryKNN(double[] center, int k, PointDistanceFunction distFn)Finds the nearest neighbor.booleanremove(double[] key, T value)Remove *one* entry with the given value.booleanremoveIf(double[] point, Predicate<PointEntry<T>> condition)Remove *one* entry with the given condition.intsize()StringtoStringTree()booleanupdate(double[] oldPoint, double[] newPoint, T value)Update the position of an entry.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.tinspin.index.PointIndexMM
query1NN
-
-
-
-
Method Detail
-
create
public static <T> PHTreeMMP<T> create(int dims)
-
getDims
public int getDims()
-
clear
public void clear()
Description copied from interface:IndexClear all entries.
-
getStats
public Stats getStats()
-
getNodeCount
public int getNodeCount()
- Specified by:
getNodeCountin interfaceIndex<T>
-
toStringTree
public String toStringTree()
- Specified by:
toStringTreein interfaceIndex<T>- Returns:
- a full string output of the tree structure with all entries
-
insert
public void insert(double[] key, T value)Description copied from interface:PointIndexMMInsert a point.- Specified by:
insertin interfacePointIndexMM<T>- Parameters:
key- pointvalue- value
-
remove
public boolean remove(double[] key, T value)Description copied from interface:PointIndexMMRemove *one* entry with the given value.- Specified by:
removein interfacePointIndexMM<T>- Parameters:
key- the pointvalue- only entries with this value are removed- Returns:
- the value of the entry or null if the entry was not found
-
removeIf
public boolean removeIf(double[] point, Predicate<PointEntry<T>> condition)Description copied from interface:PointIndexMMRemove *one* entry with the given condition.- Specified by:
removeIfin interfacePointIndexMM<T>- Parameters:
point- the pointcondition- the condition required for removing an entry- Returns:
- the value of the entry or null if the entry was not found
-
update
public boolean update(double[] oldPoint, double[] newPoint, T value)Description copied from interface:PointIndexMMUpdate the position of an entry.- Specified by:
updatein interfacePointIndexMM<T>- Parameters:
oldPoint- old positionnewPoint- new positionvalue- only entries with this value are updated- Returns:
- the value of the entry or null if the entry was not found
-
contains
public boolean contains(double[] point, T value)Description copied from interface:PointIndexMMLookup an entry, using exact match.- Specified by:
containsin interfacePointIndexMM<T>- Parameters:
point- the pointvalue- the value- Returns:
- `true` if an entry was found, otherwise `false`.
-
query
public QueryIterator<PointEntry<T>> query(double[] key)
Description copied from interface:PointIndexMMLookup an entries at a given coordinate.- Specified by:
queryin interfacePointIndexMM<T>- Parameters:
key- the point- Returns:
- an iterator over all entries at the given point
-
query
public QueryIterator<PointEntry<T>> query(double[] min, double[] max)
- Specified by:
queryin interfacePointIndexMM<T>- 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.
-
iterator
public QueryIterator<PointEntry<T>> iterator()
- Specified by:
iteratorin interfacePointIndexMM<T>- Returns:
- An iterator over all entries.
-
queryKNN
public QueryIteratorKNN<PointEntryDist<T>> queryKNN(double[] center, int k)
Description copied from interface:PointIndexMMFinds the nearest neighbor. This uses Euclidean distance. Other distance types can only be specified directly on the index implementations.- Specified by:
queryKNNin interfacePointIndexMM<T>- Parameters:
center- center pointk- number of neighbors- Returns:
- list of nearest neighbors
-
queryKNN
public QueryIteratorKNN<PointEntryDist<T>> queryKNN(double[] center, int k, PointDistanceFunction distFn)
Description copied from interface:PointIndexMMFinds the nearest neighbor. This uses Euclidean distance. Other distance types can only be specified directly on the index implementations.- Specified by:
queryKNNin interfacePointIndexMM<T>- Parameters:
center- center pointk- number of neighborsdistFn- the point distance function to be used- Returns:
- list of nearest neighbors
-
-