comparison 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
comparison
equal deleted inserted replaced
1872:db8a8a19b543 1873:e0966648ebd0
52 public: 52 public:
53 virtual ~IVisitor() 53 virtual ~IVisitor()
54 { 54 {
55 } 55 }
56 56
57 // "fullyInside" is true iff. the segment of "node" is fully
58 // inside the user-provided segment
57 virtual void Visit(const SegmentTree& node, 59 virtual void Visit(const SegmentTree& node,
58 bool fullyInside) = 0; 60 bool fullyInside) = 0;
59 }; 61 };
60 62
61 private: 63 private:
97 99
98 SegmentTree& GetRightChild() const; 100 SegmentTree& GetRightChild() const;
99 101
100 size_t CountNodes() const; 102 size_t CountNodes() const;
101 103
102 // This corresponds to both methods "INSERT()" and "DELETE()" from 104 /**
103 // the reference textbook 105 * Apply the given visitor to all the segments that intersect the
104 void Visit(size_t low, 106 * [low,high] segment. This corresponds to both methods "INSERT()"
105 size_t high, 107 * and "DELETE()" from the reference textbook.
106 IVisitor& visitor); 108 **/
109 void VisitSegment(size_t low,
110 size_t high,
111 IVisitor& visitor) const;
112
113 // For unit tests
114 const SegmentTree* FindLeaf(size_t low) const;
115
116 // For unit tests
117 const SegmentTree* FindNode(size_t low,
118 size_t high) const;
107 }; 119 };
108 } 120 }