File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -345,6 +345,18 @@ class HierarchicalClusteringIndex : public NNIndex<HierarchicalClusteringIndex<D
345
345
if (ownDataset_) {
346
346
delete[] dataset_.ptr ();
347
347
}
348
+
349
+ clearNodeTrees ();
350
+ }
351
+
352
+ /* *
353
+ * Clears Node tree
354
+ * calling Node destructor explicitly
355
+ */
356
+ void clearNodeTrees (){
357
+ for (int i=0 ; i<trees_; ++i) {
358
+ tree_roots_[i]->~Node ();
359
+ }
348
360
}
349
361
350
362
/* *
@@ -386,6 +398,7 @@ class HierarchicalClusteringIndex : public NNIndex<HierarchicalClusteringIndex<D
386
398
extendDataset (points);
387
399
388
400
if (rebuild_threshold>1 && size_at_build_*rebuild_threshold<size_) {
401
+ clearNodeTrees ();
389
402
pool_.free ();
390
403
buildIndex ();
391
404
}
@@ -501,6 +514,17 @@ class HierarchicalClusteringIndex : public NNIndex<HierarchicalClusteringIndex<D
501
514
* Level
502
515
*/
503
516
int level;
517
+
518
+ /* *
519
+ * destructor
520
+ * calling Node destructor explicitly
521
+ */
522
+ ~Node (){
523
+ for (int i=0 ; i<childs.size (); i++){
524
+ childs[i]->~Node ();
525
+ }
526
+ };
527
+
504
528
};
505
529
typedef Node* NodePtr;
506
530
You can’t perform that action at this time.
0 commit comments