예제 #1
0
 internal void find(RectangleRn r, ArrayList result, int level)
 {
     if (--level != 0)
     { /* this is an internal node in the tree */
         for (int i = 0; i < n; i++)
         {
             if (r.Intersects(b[i]))
             {
                 ((RtreeRnPage)branch[i]).find(r, result, level);
             }
         }
     }
     else
     { /* this is a leaf node */
         for (int i = 0; i < n; i++)
         {
             if (r.Intersects(b[i]))
             {
                 result.Add(branch[i]);
             }
         }
     }
 }
예제 #2
0
 internal int remove(RectangleRn r, object obj, int level, ArrayList reinsertList)
 {
     if (--level != 0)
     {
         for (int i = 0; i < n; i++)
         {
             if (r.Intersects(b[i]))
             {
                 RtreeRnPage pg = (RtreeRnPage)branch[i];
                 int reinsertLevel = pg.remove(r, obj, level, reinsertList);
                 if (reinsertLevel >= 0)
                 {
                     if (pg.n >= card/2)
                     {
                         setBranch(i, pg.cover(), pg);
                         Modify();
                     }
                     else
                     {
                         // not enough entries in child
                         reinsertList.Add(pg);
                         reinsertLevel = level - 1;
                         removeBranch(i);
                     }
                     return reinsertLevel;
                 }
             }
         }
     }
     else
     {
         for (int i = 0; i < n; i++)
         {
             if (branch.ContainsElement(i, obj))
             {
                 removeBranch(i);
                 return 0;
             }
         }
     }
     return -1;
 }