Package org.tinspin.index.array
Class PointArray<T>
- java.lang.Object
-
- org.tinspin.index.array.PointArray<T>
-
- All Implemented Interfaces:
Index,PointMap<T>,PointMultimap<T>
public class PointArray<T> extends Object implements PointMap<T>, PointMultimap<T>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.tinspin.index.Index
Index.BEComparator, Index.BoxEntry<T>, Index.BoxEntryKnn<T>, Index.BoxFilterKnn<T>, Index.BoxIterator<T>, Index.BoxIteratorKnn<T>, Index.PEComparator, Index.PointEntry<T>, Index.PointEntryKnn<T>, Index.PointFilterKnn<T>, Index.PointIterator<T>, Index.PointIteratorKnn<T>, Index.QueryIterator<T>, Index.QueryIteratorKnn<T>
-
Nested classes/interfaces inherited from interface org.tinspin.index.PointMap
PointMap.Factory
-
Nested classes/interfaces inherited from interface org.tinspin.index.PointMultimap
PointMultimap.Factory
-
-
Constructor Summary
Constructors Constructor Description PointArray(int dims, int size)Setup of a simple array data structure (no indexing).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clear all entries.booleancontains(double[] key)Lookup an entry, using exact match.booleancontains(double[] point, T value)Lookup an entry, using exact match.intgetDepth()intgetDims()intgetNodeCount()StatsgetStats()voidinsert(double[] key, T value)Insert a point.Index.PointIterator<T>iterator()org.tinspin.index.array.PointArray.AQueryIteratorquery(double[] min, double[] max)Index.PointEntryKnn<T>query1nn(double[] center)Finds the nearest neighbor.TqueryExact(double[] point)Lookup an entry, using exact match.Index.PointIterator<T>queryExactPoint(double[] point)Lookup an entries at a given coordinate.org.tinspin.index.array.PointArray.AQueryIteratorKnnqueryKnn(double[] center, int k)Finds the nearest neighbor.Index.PointIteratorKnn<T>queryKnn(double[] center, int k, PointDistance distFn)Finds the nearest neighbor.Tremove(double[] point)Remove a point entry.booleanremove(double[] point, T value)Remove *one* entry with the given value.booleanremoveIf(double[] point, Predicate<Index.PointEntry<T>> condition)Remove *one* entry with the given condition.intsize()StringtoString()StringtoStringTree()Tupdate(double[] oldPoint, double[] newPoint)Update the position of an entry.booleanupdate(double[] oldPoint, double[] newPoint, T value)Update the position of an entry.
-
-
-
Method Detail
-
insert
public void insert(double[] key, T value)Description copied from interface:PointMapInsert a point.
-
remove
public boolean remove(double[] point, T value)Description copied from interface:PointMultimapRemove *one* entry with the given value.- Specified by:
removein interfacePointMultimap<T>- Parameters:
point- 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<Index.PointEntry<T>> condition)Description copied from interface:PointMultimapRemove *one* entry with the given condition.- Specified by:
removeIfin interfacePointMultimap<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
-
queryExactPoint
public Index.PointIterator<T> queryExactPoint(double[] point)
Description copied from interface:PointMultimapLookup an entries at a given coordinate.- Specified by:
queryExactPointin interfacePointMultimap<T>- Parameters:
point- the point- Returns:
- an iterator over all entries at the given point
-
contains
public boolean contains(double[] key)
Description copied from interface:PointMapLookup an entry, using exact match.
-
queryExact
public T queryExact(double[] point)
Description copied from interface:PointMapLookup an entry, using exact match.- Specified by:
queryExactin interfacePointMap<T>- Parameters:
point- the point- 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:PointMultimapLookup an entry, using exact match.- Specified by:
containsin interfacePointMultimap<T>- Parameters:
point- the pointvalue- the value- Returns:
- `true` if an entry was found, otherwise `false`.
-
query
public org.tinspin.index.array.PointArray.AQueryIterator query(double[] min, double[] max)
-
query1nn
public Index.PointEntryKnn<T> query1nn(double[] center)
Description copied from interface:PointMapFinds the nearest neighbor. This uses Euclidean distance. Other distance types can only be specified directly on the index implementations.
-
iterator
public Index.PointIterator<T> iterator()
-
queryKnn
public org.tinspin.index.array.PointArray.AQueryIteratorKnn queryKnn(double[] center, int k)Description copied from interface:PointMapFinds the nearest neighbor. This uses Euclidean distance. Other distance types can only be specified directly on the index implementations.
-
queryKnn
public Index.PointIteratorKnn<T> queryKnn(double[] center, int k, PointDistance distFn)
Description copied from interface:PointMultimapFinds the nearest neighbor. This uses Euclidean distance. Other distance types can only be specified directly on the index implementations.- Specified by:
queryKnnin interfacePointMultimap<T>- Parameters:
center- center pointk- number of neighborsdistFn- the point distance function to be used- Returns:
- list of nearest neighbors
-
update
public T update(double[] oldPoint, double[] newPoint)
Description copied from interface:PointMapUpdate the position of an entry.
-
update
public boolean update(double[] oldPoint, double[] newPoint, T value)Description copied from interface:PointMultimapUpdate the position of an entry.- Specified by:
updatein interfacePointMultimap<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
-
remove
public T remove(double[] point)
Description copied from interface:PointMapRemove a point entry.
-
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
-
toStringTree
public String toStringTree()
- Specified by:
toStringTreein interfaceIndex- Returns:
- a full string output of the tree structure with all entries
-
-