diff OrthancStone/Sources/Toolbox/SegmentTree.h @ 1873:e0966648ebd0

unit tests of SegmentTree
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 11 Jan 2022 15:36:04 +0100
parents db8a8a19b543
children 07964689cb0b
line wrap: on
line diff
--- a/OrthancStone/Sources/Toolbox/SegmentTree.h	Tue Jan 11 12:15:22 2022 +0100
+++ b/OrthancStone/Sources/Toolbox/SegmentTree.h	Tue Jan 11 15:36:04 2022 +0100
@@ -54,6 +54,8 @@
       {
       }
 
+      // "fullyInside" is true iff. the segment of "node" is fully
+      // inside the user-provided segment
       virtual void Visit(const SegmentTree& node,
                          bool fullyInside) = 0;
     };
@@ -99,10 +101,20 @@
 
     size_t CountNodes() const;
 
-    // This corresponds to both methods "INSERT()" and "DELETE()" from
-    // the reference textbook
-    void Visit(size_t low,
-               size_t high,
-               IVisitor& visitor);
+    /**
+     * Apply the given visitor to all the segments that intersect the
+     * [low,high] segment. This corresponds to both methods "INSERT()"
+     * and "DELETE()" from the reference textbook.
+     **/
+    void VisitSegment(size_t low,
+                      size_t high,
+                      IVisitor& visitor) const;
+
+    // For unit tests
+    const SegmentTree* FindLeaf(size_t low) const;
+
+    // For unit tests
+    const SegmentTree* FindNode(size_t low,
+                                size_t high) const;
   };
 }