Package org.tinspin.index.array
Class RectArray<T>
- java.lang.Object
-
- org.tinspin.index.array.RectArray<T>
-
- All Implemented Interfaces:
BoxMap<T>,BoxMultimap<T>,Index
public class RectArray<T> extends Object implements BoxMap<T>, BoxMultimap<T>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.tinspin.index.BoxMap
BoxMap.Factory
-
Nested classes/interfaces inherited from interface org.tinspin.index.BoxMultimap
BoxMultimap.Factory
-
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>
-
-
Constructor Summary
Constructors Constructor Description RectArray(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[] min, double[] max)Lookup an entry, using exact match.booleancontains(double[] lower, double[] upper, T value)Lookup an entry, using exact match.intgetDepth()intgetDims()intgetNodeCount()StatsgetStats()voidinsert(double[] lower, double[] upper, T value)Insert a box.Index.BoxIterator<T>iterator()Index.BoxEntryKnn<T>query1nn(double[] center)Finds the nearest neighbor.TqueryExact(double[] lower, double[] upper)Lookup an entry, using exact match.Index.BoxIterator<T>queryExactBox(double[] lower, double[] upper)Lookup an entry, using exact match.Index.BoxIterator<T>queryIntersect(double[] min, double[] max)Index.BoxIteratorKnn<T>queryKnn(double[] center, int k)Finds the nearest neighbor.Index.BoxIteratorKnn<T>queryKnn(double[] center, int k, BoxDistance distFn)Finds the nearest neighbor.Tremove(double[] lower, double[] upper)Remove an entry.booleanremove(double[] lower, double[] upper, T value)Remove *one*n entry with the given value.booleanremoveIf(double[] lower, double[] upper, Predicate<Index.BoxEntry<T>> condition)Remove *one* entry with the given condition.intsize()StringtoString()StringtoStringTree()Tupdate(double[] lo1, double[] up1, double[] lo2, double[] up2)Update the position of an entry.booleanupdate(double[] lo1, double[] up1, double[] lo2, double[] up2, T value)Update the position of an entry.
-
-
-
Method Detail
-
insert
public void insert(double[] lower, double[] upper, T value)Description copied from interface:BoxMapInsert a box.
-
remove
public T remove(double[] lower, double[] upper)
Description copied from interface:BoxMapRemove an entry.
-
remove
public boolean remove(double[] lower, double[] upper, T value)Description copied from interface:BoxMultimapRemove *one*n entry with the given value.- Specified by:
removein interfaceBoxMultimap<T>- Parameters:
lower- minimum cornerupper- maximum cornervalue- value- Returns:
- the value of the entry or null if the entry was not found
-
removeIf
public boolean removeIf(double[] lower, double[] upper, Predicate<Index.BoxEntry<T>> condition)Description copied from interface:BoxMultimapRemove *one* entry with the given condition.- Specified by:
removeIfin interfaceBoxMultimap<T>- Parameters:
lower- minimum cornerupper- maximum cornercondition- the condition required for removing an entry- Returns:
- the value of the entry or null if the entry was not found
-
update
public T update(double[] lo1, double[] up1, double[] lo2, double[] up2)
Description copied from interface:BoxMapUpdate the position of an entry.
-
contains
public boolean contains(double[] min, double[] max)Description copied from interface:BoxMapLookup an entry, using exact match.
-
update
public boolean update(double[] lo1, double[] up1, double[] lo2, double[] up2, T value)Description copied from interface:BoxMultimapUpdate the position of an entry.- Specified by:
updatein interfaceBoxMultimap<T>- Parameters:
lo1- old minup1- old maxlo2- new minup2- new maxvalue- only entries with this value are updated- Returns:
- the value, or null if the entries was not found
-
queryExact
public T queryExact(double[] lower, double[] upper)
Description copied from interface:BoxMapLookup an entry, using exact match.- Specified by:
queryExactin interfaceBoxMap<T>- Parameters:
lower- minimum cornerupper- maximum corner- Returns:
- the value of the entry or null if the entry was not found
-
contains
public boolean contains(double[] lower, double[] upper, T value)Description copied from interface:BoxMultimapLookup an entry, using exact match.- Specified by:
containsin interfaceBoxMultimap<T>- Parameters:
lower- minimum cornerupper- maximum cornervalue- the value- Returns:
- `true` if an entry was found, otherwise `false`.
-
queryExactBox
public Index.BoxIterator<T> queryExactBox(double[] lower, double[] upper)
Description copied from interface:BoxMultimapLookup an entry, using exact match.- Specified by:
queryExactBoxin interfaceBoxMultimap<T>- Parameters:
lower- minimum cornerupper- maximum corner- Returns:
- an iterator over all entries with the exact given box shape
-
queryIntersect
public Index.BoxIterator<T> queryIntersect(double[] min, double[] max)
- Specified by:
queryIntersectin interfaceBoxMap<T>- Specified by:
queryIntersectin interfaceBoxMultimap<T>- Parameters:
min- Lower left corner of the query windowmax- Upper right corner of the query window- Returns:
- All boxes that intersect with the query rectangle.
-
query1nn
public Index.BoxEntryKnn<T> query1nn(double[] center)
Description copied from interface:BoxMapFinds the nearest neighbor. This uses Euclidean 'edge distance'. Other distance types can only be specified directly on the index implementations.
-
iterator
public Index.BoxIterator<T> iterator()
-
queryKnn
public Index.BoxIteratorKnn<T> queryKnn(double[] center, int k)
Description copied from interface:BoxMapFinds the nearest neighbor. This uses Euclidean 'edge distance', i.e. the distance to the edge of a box. Distance is 0 if the box overlaps with the search point. Other distance types can only be specified directly on the index implementations.
-
queryKnn
public Index.BoxIteratorKnn<T> queryKnn(double[] center, int k, BoxDistance distFn)
Description copied from interface:BoxMultimapFinds the nearest neighbor. This uses a custom distance function for distances to boxes.- Specified by:
queryKnnin interfaceBoxMultimap<T>- Parameters:
center- center pointk- number of neighborsdistFn- distance function- Returns:
- list of nearest neighbors
-
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
-
-