From 4df8109ecc2453f69059ebea0f3667d4aa037f02 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sat, 7 May 2022 10:59:40 -0700 Subject: [PATCH] label: remove unused 'RTreeDelete' --- lib/label/index.c | 139 ---------------------------------------------- lib/label/index.h | 1 - 2 files changed, 140 deletions(-) diff --git a/lib/label/index.c b/lib/label/index.c index 3cb09bde4..9aa4d72c9 100644 --- a/lib/label/index.c +++ b/lib/label/index.c @@ -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; - } -} diff --git a/lib/label/index.h b/lib/label/index.h index 329f94dcb..5bf0df93a 100644 --- a/lib/label/index.h +++ b/lib/label/index.h @@ -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); -- 2.40.0