@@ -1422,100 +1422,6 @@ namespace lib_interval_tree
1422
1422
return punch ({min, max});
1423
1423
}
1424
1424
1425
- // TODO: private
1426
- /* *
1427
- * @brief Finds the interval that is right of the given value and does not contain it.
1428
- * Only works with deoverlapped trees.
1429
- *
1430
- * @param low
1431
- * @return node_type*
1432
- */
1433
- node_type* find_directly_right_of_i (value_type search_value) const
1434
- {
1435
- if (empty ())
1436
- return nullptr ;
1437
-
1438
- // There can be no interval strictly right of the value, if the value
1439
- // is larger than the max.
1440
- if (search_value > root_->max_ )
1441
- return nullptr ;
1442
-
1443
- const auto is_interval_strictly_right_of_value = [search_value](node_type* node) {
1444
- return node->low () > search_value ||
1445
- (node->low () == search_value && !node->interval ()->within (search_value));
1446
- };
1447
-
1448
- auto * node = root_;
1449
-
1450
- // If the interval is not strictly right of the value, we can only go down right
1451
- // And dont have to check left.
1452
- while (!is_interval_strictly_right_of_value (node) && node->right_ )
1453
- node = node->right_ ;
1454
-
1455
- bool go_left = false ;
1456
- bool go_right = false ;
1457
- do
1458
- {
1459
- go_left = node->left_ && is_interval_strictly_right_of_value (node->left_ );
1460
- go_right = node->right_ && is_interval_strictly_right_of_value (node->right_ );
1461
-
1462
- if (go_left)
1463
- node = node->left_ ;
1464
- else if (go_right)
1465
- node = node->right_ ;
1466
- } while (go_left || go_right);
1467
-
1468
- if (is_interval_strictly_right_of_value (node))
1469
- return node;
1470
-
1471
- // We only end up here when node == root_, otherwise we never went down the tree to begin with.
1472
- return nullptr ;
1473
- }
1474
-
1475
- /* *
1476
- * @brief Find the interval that is left of the given value or contains it.
1477
- * Only works in deoverlapped trees. Because a deoverlapped tree is indistinguishable
1478
- * from a regular binary search tree. The tree is then also sorted by the upper interval bound.
1479
- * Making this search possible in the first place.
1480
- *
1481
- * @param search_value
1482
- * @return node_type*
1483
- */
1484
- node_type* find_leftest_interval_of_value_i (value_type search_value) const
1485
- {
1486
- if (empty ())
1487
- return nullptr ;
1488
-
1489
- auto * node = root_;
1490
-
1491
- // low of a node is always lower than the lows of all nodes right of that node
1492
- // high of a node is always lower than the lows of all nodes right of that node
1493
-
1494
- bool go_left = false ;
1495
- bool go_right = false ;
1496
-
1497
- do
1498
- {
1499
- go_right = search_value > node->high ();
1500
- if (go_right)
1501
- {
1502
- go_right &= node->right_ != nullptr ;
1503
- if (go_right)
1504
- node = node->right_ ;
1505
- continue ;
1506
- }
1507
-
1508
- go_left = node->left_ != nullptr && search_value < node->low ();
1509
- if (go_left)
1510
- node = node->left_ ;
1511
- } while (go_left || go_right);
1512
-
1513
- if (search_value < node->low ())
1514
- return nullptr ;
1515
-
1516
- return node;
1517
- }
1518
-
1519
1425
/* *
1520
1426
* Only works with deoverlapped trees.
1521
1427
* Removes all intervals from the given interval and produces a tree that contains the remaining intervals.
@@ -1563,7 +1469,6 @@ namespace lib_interval_tree
1563
1469
if (ex.right_slice )
1564
1470
{
1565
1471
ival = std::move (*ex.right_slice );
1566
- // TODO: Can I avoid assigning this every loop? -> maybe by extracting the first iteration?
1567
1472
insert_remaining = true ;
1568
1473
}
1569
1474
else
@@ -1672,6 +1577,50 @@ namespace lib_interval_tree
1672
1577
}
1673
1578
1674
1579
private:
1580
+ /* *
1581
+ * @brief Find the interval that is left of the given value or contains it.
1582
+ * Only works in deoverlapped trees. Because a deoverlapped tree is indistinguishable
1583
+ * from a regular binary search tree. The tree is then also sorted by the upper interval bound.
1584
+ * Making this search possible in the first place.
1585
+ *
1586
+ * @param search_value
1587
+ * @return node_type*
1588
+ */
1589
+ node_type* find_leftest_interval_of_value_i (value_type search_value) const
1590
+ {
1591
+ if (empty ())
1592
+ return nullptr ;
1593
+
1594
+ auto * node = root_;
1595
+
1596
+ // low of a node is always lower than the lows of all nodes right of that node
1597
+ // high of a node is always lower than the lows of all nodes right of that node
1598
+
1599
+ bool go_left = false ;
1600
+ bool go_right = false ;
1601
+
1602
+ do
1603
+ {
1604
+ go_right = search_value > node->high ();
1605
+ if (go_right)
1606
+ {
1607
+ go_right &= node->right_ != nullptr ;
1608
+ if (go_right)
1609
+ node = node->right_ ;
1610
+ continue ;
1611
+ }
1612
+
1613
+ go_left = node->left_ != nullptr && search_value < node->low ();
1614
+ if (go_left)
1615
+ node = node->left_ ;
1616
+ } while (go_left || go_right);
1617
+
1618
+ if (search_value < node->low ())
1619
+ return nullptr ;
1620
+
1621
+ return node;
1622
+ }
1623
+
1675
1624
node_type* copy_tree_impl (node_type* root, node_type* parent)
1676
1625
{
1677
1626
if (root)
0 commit comments