Package org.tinspin.index.array
Class RectArray<T>
- java.lang.Object
-
- org.tinspin.index.array.RectArray<T>
-
- All Implemented Interfaces:
Index<T>,RectangleIndex<T>,RectangleIndexMM<T>
public class RectArray<T> extends Object implements RectangleIndex<T>, RectangleIndexMM<T>
-
-
Constructor Summary
Constructors Constructor Description RectArray(int dims, int size)Setup of an 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[] lower, double[] upper, T value)Lookup an entry, using exact match.intgetDepth()intgetDims()intgetNodeCount()StatsgetStats()voidinsert(double[] lower, double[] upper, T value)Insert a rectangle.QueryIterator<RectangleEntry<T>>iterator()RectangleEntryDist<T>query1NN(double[] center)Finds the nearest neighbor.TqueryExact(double[] lower, double[] upper)Lookup an entry, using exact match.QueryIterator<RectangleEntry<T>>queryIntersect(double[] min, double[] max)QueryIteratorKNN<RectangleEntryDist<T>>queryKNN(double[] center, int k)Finds the nearest neighbor.QueryIteratorKNN<RectangleEntryDist<T>>queryKNN(double[] center, int k, RectangleDistanceFunction distFn)Finds the nearest neighbor.QueryIterator<RectangleEntry<T>>queryRectangle(double[] lower, double[] upper)Lookup an entry, using exact match.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<RectangleEntry<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:RectangleIndexInsert a rectangle.- Specified by:
insertin interfaceRectangleIndex<T>- Specified by:
insertin interfaceRectangleIndexMM<T>- Parameters:
lower- minimum cornerupper- maximum cornervalue- value
-
remove
public T remove(double[] lower, double[] upper)
Description copied from interface:RectangleIndexRemove an entry.- Specified by:
removein interfaceRectangleIndex<T>- Parameters:
lower- minimum cornerupper- maximum corner- Returns:
- the value of the entry or null if the entry was not found
-
remove
public boolean remove(double[] lower, double[] upper, T value)Description copied from interface:RectangleIndexMMRemove *one*n entry with the given value.- Specified by:
removein interfaceRectangleIndexMM<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<RectangleEntry<T>> condition)Description copied from interface:RectangleIndexMMRemove *one* entry with the given condition.- Specified by:
removeIfin interfaceRectangleIndexMM<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:RectangleIndexUpdate the position of an entry.- Specified by:
updatein interfaceRectangleIndex<T>- Parameters:
lo1- old minup1- old maxlo2- new minup2- new max- Returns:
- the value, or null if the entries was not found
-
update
public boolean update(double[] lo1, double[] up1, double[] lo2, double[] up2, T value)Description copied from interface:RectangleIndexMMUpdate the position of an entry.- Specified by:
updatein interfaceRectangleIndexMM<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:RectangleIndexLookup an entry, using exact match.- Specified by:
queryExactin interfaceRectangleIndex<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:RectangleIndexMMLookup an entry, using exact match.- Specified by:
containsin interfaceRectangleIndexMM<T>- Parameters:
lower- minimum cornerupper- maximum cornervalue- the value- Returns:
- `true` if an entry was found, otherwise `false`.
-
queryRectangle
public QueryIterator<RectangleEntry<T>> queryRectangle(double[] lower, double[] upper)
Description copied from interface:RectangleIndexMMLookup an entry, using exact match.- Specified by:
queryRectanglein interfaceRectangleIndexMM<T>- Parameters:
lower- minimum cornerupper- maximum corner- Returns:
- an iterator over all entries at with the exact given rectangle
-
queryIntersect
public QueryIterator<RectangleEntry<T>> queryIntersect(double[] min, double[] max)
- Specified by:
queryIntersectin interfaceRectangleIndex<T>- Specified by:
queryIntersectin interfaceRectangleIndexMM<T>- Parameters:
min- Lower left corner of the query windowmax- Upper right corner of the query window- Returns:
- All rectangles that intersect with the query rectangle.
-
query1NN
public RectangleEntryDist<T> query1NN(double[] center)
Description copied from interface:RectangleIndexFinds the nearest neighbor. This uses euclidean 'edge distance'. Other distance types can only be specified directly on the index implementations.- Specified by:
query1NNin interfaceRectangleIndex<T>- Specified by:
query1NNin interfaceRectangleIndexMM<T>- Parameters:
center- center point- Returns:
- the nearest neighbor
-
iterator
public QueryIterator<RectangleEntry<T>> iterator()
- Specified by:
iteratorin interfaceRectangleIndex<T>- Specified by:
iteratorin interfaceRectangleIndexMM<T>- Returns:
- An iterator over all entries.
-
queryKNN
public QueryIteratorKNN<RectangleEntryDist<T>> queryKNN(double[] center, int k)
Description copied from interface:RectangleIndexFinds the nearest neighbor. This uses euclidean 'edge distance', i.e. the distance to the edge of rectangle. Distance is 0 is the rectangle overlaps with the search point. Other distance types can only be specified directly on the index implementations.- Specified by:
queryKNNin interfaceRectangleIndex<T>- Specified by:
queryKNNin interfaceRectangleIndexMM<T>- Parameters:
center- center pointk- number of neighbors- Returns:
- list of nearest neighbors
-
queryKNN
public QueryIteratorKNN<RectangleEntryDist<T>> queryKNN(double[] center, int k, RectangleDistanceFunction distFn)
Description copied from interface:RectangleIndexMMFinds the nearest neighbor. This uses a custom distance function for distances to rectangles.- Specified by:
queryKNNin interfaceRectangleIndexMM<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<T>
-
toStringTree
public String toStringTree()
- Specified by:
toStringTreein interfaceIndex<T>- Returns:
- a full string output of the tree structure with all entries
-
-