]> granicus.if.org Git - graphviz/commitdiff
label: remove unused 'RTreeDelete'
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 7 May 2022 17:59:40 +0000 (10:59 -0700)
committerMagnus Jacobsson <Magnus.Jacobsson@berotec.se>
Sat, 18 Jun 2022 14:44:13 +0000 (16:44 +0200)
lib/label/index.c
lib/label/index.h

index 3cb09bde4850552724ddf39e2b01d8c8d2150670..9aa4d72c93da0afa4c35bc96c7f65d8600cbe0ed 100644 (file)
@@ -49,29 +49,6 @@ void RTreeLeafListFree(LeafList_t * llp)
     return;
 }
 
-/* Allocate space for a node in the list used in DeletRect to
- * store Nodes that are too empty.
- */
-static struct ListNode *RTreeNewListNode(void)
-{
-    return calloc(1, sizeof(struct ListNode));
-}
-
-/* Add a node to the reinsertion list.  All its branches will later
- * be reinserted into the index structure.
- */
-static int RTreeReInsert(Node_t * n, struct ListNode **ee)
-{
-    struct ListNode *l;
-
-    if (!(l = RTreeNewListNode()))
-       return -1;
-    l->node = n;
-    l->next = *ee;
-    *ee = l;
-    return 0;
-}
-
 RTree_t *RTreeOpen()
 {
     RTree_t *rtp;
@@ -312,119 +289,3 @@ RTreeInsert2(RTree_t * rtp, Rect_t * r, void *data,
        return 0;
     }
 }
-
-static void FreeListNode(struct ListNode *p)
-{
-    free(p);
-}
-
-/* Delete a data rectangle from an index structure.
-** Pass in a pointer to a Rect, the data of the record, ptr to ptr to root node.
-** Returns 1 if record not found, 0 if success.
-** RTreeDelete provides for eliminating the root.
-*/
-static int RTreeDelete2(RTree_t *, Rect_t *, void *, Node_t *,
-                       ListNode_t **);
-
-int RTreeDelete(RTree_t * rtp, Rect_t * r, void *data, Node_t ** nn)
-{
-    Node_t *t;
-    struct ListNode *reInsertList = NULL;
-
-    assert(r && nn);
-    assert(*nn);
-    assert(data);
-
-    rtp->Deleting = TRUE;
-
-#      ifdef RTDEBUG
-    fprintf(stderr, "RTreeDelete\n");
-#      endif
-
-    if (!RTreeDelete2(rtp, r, data, *nn, &reInsertList)) {
-       /* found and deleted a data item */
-       if (rtp->StatFlag)
-           rtp->DeleteCount++;
-       rtp->RectCount--;
-
-       /* reinsert any branches from eliminated nodes */
-       while (reInsertList) {
-           t = reInsertList->node;
-           for (size_t i = 0; i < NODECARD; i++) {
-               if (t->branch[i].child) {
-                   RTreeInsert(rtp, &(t->branch[i].rect),
-                               t->branch[i].child, nn, t->level);
-                   rtp->EntryCount--;
-               }
-           }
-           struct ListNode *e = reInsertList;
-           reInsertList = reInsertList->next;
-           RTreeFreeNode(rtp, e->node);
-           FreeListNode(e);
-       }
-
-       /* check for redundant root (not leaf, 1 child) and eliminate */
-       if ((*nn)->count == 1 && (*nn)->level > 0) {
-           if (rtp->StatFlag)
-               rtp->ElimCount++;
-           rtp->EntryCount--;
-           for (size_t i = 0; i < NODECARD; i++) {
-               if ((t = (*nn)->branch[i].child))
-                   break;
-           }
-           RTreeFreeNode(rtp, *nn);
-           *nn = t;
-       }
-       rtp->Deleting = FALSE;
-       return 0;
-    } else {
-       rtp->Deleting = FALSE;
-       return 1;
-    }
-}
-
-/* Delete a rectangle from non-root part of an index structure.
-** Called by RTreeDelete.  Descends tree recursively,
-** merges branches on the way back up.
-*/
-static int
-RTreeDelete2(RTree_t * rtp, Rect_t * r, void *data, Node_t * n,
-            ListNode_t ** ee)
-{
-    assert(r && n && ee);
-    assert(data);
-    assert(n->level >= 0);
-
-    if (rtp->StatFlag)
-       rtp->DeTouchCount++;
-
-    if (n->level > 0) {                /* not a leaf node */
-       for (int i = 0; i < NODECARD; i++) {
-           if (n->branch[i].child && Overlap(r, &(n->branch[i].rect))) {
-               if (!RTreeDelete2(rtp, r, data, n->branch[i].child, ee)) {      /*recurse */
-                   if (n->branch[i].child->count >= rtp->MinFill)
-                       n->branch[i].rect = NodeCover(n->branch[i].child);
-                   else {      /* not enough entries in child, eliminate child node */
-                       RTreeReInsert(n->branch[i].child, ee);
-                       DisconBranch(n, i);
-                       rtp->EntryCount--;
-                       if (rtp->StatFlag)
-                           rtp->ElimCount++;
-                   }
-                   return 0;
-               }
-           }
-       }
-       return 1;
-    } else {                   /* a leaf node */
-       for (int i = 0; i < NODECARD; i++) {
-           if (n->branch[i].child
-               && n->branch[i].child == (Node_t *) data) {
-               DisconBranch(n, i);
-               rtp->EntryCount--;
-               return 0;
-           }
-       }
-       return 1;
-    }
-}
index 329f94dcbe49e3afdf0c607eed7aeaa40aec511f..5bf0df93a6a299ee0fb6a650d0926b2ca19205f5 100644 (file)
@@ -115,7 +115,6 @@ int RTreeClose(RTree_t * rtp);
 Node_t *RTreeNewIndex(RTree_t * rtp);
 LeafList_t *RTreeSearch(RTree_t *, Node_t *, Rect_t *);
 int RTreeInsert(RTree_t *, Rect_t *, void *, Node_t **, int);
-int RTreeDelete(RTree_t *, Rect_t *, void *, Node_t **);
 
 LeafList_t *RTreeNewLeafList(Leaf_t * lp);
 LeafList_t *RTreeLeafListAdd(LeafList_t * llp, Leaf_t * lp);