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