Esempio n. 1
0
 public void remove(RectangleR2 r, T obj) {
   if (root == null) {
     throw new StorageError(StorageError.KEY_NOT_FOUND);
   }
   ArrayList reinsertList = new ArrayList();
   int reinsertLevel = root.remove(r, obj, height, reinsertList);
   if (reinsertLevel < 0) {
     throw new StorageError(StorageError.KEY_NOT_FOUND);
   }
   for (int i = reinsertList.size(); --i >= 0; ) {
     RtreeR2Page p = (RtreeR2Page) reinsertList.get(i);
     for (int j = 0, n = p.n; j < n; j++) {
       RtreeR2Page q = root.insert(getStorage(), p.b[j], p.branch.get(j), height - reinsertLevel);
       if (q != null) {
         // root splitted
         root = new RtreeR2Page(getStorage(), root, q);
         height += 1;
       }
     }
     reinsertLevel -= 1;
     p.deallocate();
   }
   if (root.n == 1 && height > 1) {
     RtreeR2Page newRoot = (RtreeR2Page) root.branch.get(0);
     root.deallocate();
     root = newRoot;
     height -= 1;
   }
   n -= 1;
   updateCounter += 1;
   modify();
 }
Esempio n. 2
0
 public ArrayList<T> getList(RectangleR2 r) {
   ArrayList<T> result = new ArrayList<T>();
   if (root != null) {
     root.find(r, result, height);
   }
   return result;
 }
Esempio n. 3
0
 public Object[] get(RectangleR2 r) {
   ArrayList result = new ArrayList();
   if (root != null) {
     root.find(r, result, height);
   }
   return result.toArray();
 }
Esempio n. 4
0
 public void clear() {
   if (root != null) {
     root.purge(height);
     root = null;
   }
   height = 0;
   n = 0;
   updateCounter += 1;
   modify();
 }
Esempio n. 5
0
 public void put(RectangleR2 r, T obj) {
   Storage db = getStorage();
   if (root == null) {
     root = new RtreeR2Page(db, obj, r);
     height = 1;
   } else {
     RtreeR2Page p = root.insert(db, r, obj, height);
     if (p != null) {
       root = new RtreeR2Page(db, root, p);
       height += 1;
     }
   }
   n += 1;
   updateCounter += 1;
   modify();
 }
Esempio n. 6
0
 public RectangleR2 getWrappingRectangle() {
   if (root != null) {
     return root.cover();
   }
   return null;
 }