org.garret.perst
Interface SpatialIndex<T extends IPersistent>

All Superinterfaces:
java.util.Collection, java.io.Externalizable, IPersistent, IResource, ITable, java.lang.Iterable, java.io.Serializable

public interface SpatialIndex<T extends IPersistent>
extends IPersistent, IResource, ITable<T>

Interface of object spatial index. Spatial index is used to allow fast selection of spatial objects belonging to the specified rectangle. Spatial index is implemented using Guttman R-Tree with quadratic split algorithm.


Method Summary
 void clear()
          Remove all objects from the index
 IterableIterator<java.util.Map.Entry<Rectangle,T>> entryIterator()
          Get entry iterator through all members of the index This iterator doesn't support remove() method.
 IterableIterator<java.util.Map.Entry<Rectangle,T>> entryIterator(Rectangle r)
          Get entry iterator through objects which rectangle intersects with specified rectangle This iterator doesn't support remove() method.
 IPersistent[] get(Rectangle r)
          Find all objects located in the selected rectangle
 java.util.ArrayList<T> getList(Rectangle r)
          Find all objects located in the selected rectangle
 Rectangle getWrappingRectangle()
          Get wrapping rectangle
 java.util.Iterator<T> iterator()
          Get iterator through all members of the index This iterator doesn't support remove() method.
 IterableIterator<T> iterator(Rectangle r)
          Get objects which rectangle intersects with specified rectangle This iterator doesn't support remove() method.
 void put(Rectangle r, T obj)
          Put new object in the index.
 void remove(Rectangle r, T obj)
          Remove object with specified enveloping rectangle from the tree.
 int size()
          Get number of objects in the index
 
Methods inherited from interface org.garret.perst.IPersistent
assignOid, deallocate, getOid, getStorage, invalidate, isDeleted, isModified, isPersistent, isRaw, load, loadAndModify, makePersistent, modify, onLoad, onStore, recursiveLoading, store
 
Methods inherited from interface java.io.Externalizable
readExternal, writeExternal
 
Methods inherited from interface org.garret.perst.IResource
exclusiveLock, exclusiveLock, reset, sharedLock, sharedLock, unlock
 
Methods inherited from interface org.garret.perst.ITable
select
 
Methods inherited from interface java.util.Collection
add, addAll, contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Method Detail

clear

void clear()
Remove all objects from the index

Specified by:
clear in interface java.util.Collection

entryIterator

IterableIterator<java.util.Map.Entry<Rectangle,T>> entryIterator()
Get entry iterator through all members of the index This iterator doesn't support remove() method. It is not possible to modify spatial index during iteration.

Returns:
entry iterator which key specifies recrtangle and value - correspondent object

entryIterator

IterableIterator<java.util.Map.Entry<Rectangle,T>> entryIterator(Rectangle r)
Get entry iterator through objects which rectangle intersects with specified rectangle This iterator doesn't support remove() method. It is not possible to modify spatial index during iteration.

Parameters:
r - selected rectangle
Returns:
entry iterator for objects which enveloping rectangle overlaps with specified rectangle

get

IPersistent[] get(Rectangle r)
Find all objects located in the selected rectangle

Parameters:
r - selected rectangle
Returns:
array of objects which enveloping rectangle intersects with specified rectangle

getList

java.util.ArrayList<T> getList(Rectangle r)
Find all objects located in the selected rectangle

Parameters:
r - selected rectangle
Returns:
array list of objects which enveloping rectangle intersects with specified rectangle

getWrappingRectangle

Rectangle getWrappingRectangle()
Get wrapping rectangle

Returns:
minimal rectangle containing all rectangles in the index, null if index is empty

iterator

java.util.Iterator<T> iterator()
Get iterator through all members of the index This iterator doesn't support remove() method. It is not possible to modify spatial index during iteration.

Specified by:
iterator in interface java.util.Collection
Returns:
iterator through all objects in the index

iterator

IterableIterator<T> iterator(Rectangle r)
Get objects which rectangle intersects with specified rectangle This iterator doesn't support remove() method. It is not possible to modify spatial index during iteration.

Parameters:
r - selected rectangle
Returns:
iterator for objects which enveloping rectangle overlaps with specified rectangle

put

void put(Rectangle r,
         T obj)
Put new object in the index.

Parameters:
r - enveloping rectangle for the object
obj - object associated with this rectangle. Object can be not yet persistent, in this case its forced to become persistent by assigning OID to it.

remove

void remove(Rectangle r,
            T obj)
Remove object with specified enveloping rectangle from the tree.

Parameters:
r - enveloping rectangle for the object
obj - object removed from the index
Throws:
StorageError(StorageError.KEY_NOT_FOUND) - exception if there is no such key in the index

size

int size()
Get number of objects in the index

Specified by:
size in interface java.util.Collection
Returns:
number of objects in the index