示例#1
0
 public Object[] get(RectangleR2 r) {
   ArrayList result = new ArrayList();
   if (root != null) {
     root.find(r, result, height);
   }
   return result.toArray();
 }
示例#2
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();
 }