Skip to content

Commit 00ad98f

Browse files
committed
Added adjacent closed punch drawing.
1 parent c189555 commit 00ad98f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

drawings/example_drawings.hpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,32 @@ static void drawClosedPunchExample()
151151
drawTree("drawings/closed_punched.png", punched, false, false);
152152
}
153153

154+
static void drawAdjacentClosedPunchExample()
155+
{
156+
constexpr int iterations = 5;
157+
using namespace lib_interval_tree;
158+
159+
interval_tree<interval<int, closed_adjacent>> tree;
160+
161+
// insert shuffled into new tree
162+
std::vector<std::pair<int, int>> intervals;
163+
for (int i = 0; i < iterations; ++i)
164+
{
165+
intervals.emplace_back(i * 10, i * 10 + 5);
166+
}
167+
168+
std::mt19937 rng(std::random_device{}());
169+
std::shuffle(intervals.begin(), intervals.end(), rng);
170+
for (const auto& interval : intervals)
171+
{
172+
tree.insert({interval.first, interval.second});
173+
}
174+
175+
drawTree("drawings/closed_adjacent_punch_source.png", tree, false, false);
176+
const auto punched = tree.punch({-10, iterations * 10 + 10});
177+
drawTree("drawings/closed_adjacent_punched.png", punched, false, false);
178+
}
179+
154180
static void drawFloatPunchExample()
155181
{
156182
constexpr int iterations = 5;
@@ -184,5 +210,6 @@ static void drawAll()
184210
drawLargeOverlapFree();
185211
drawOpenPunchExample();
186212
drawClosedPunchExample();
213+
drawAdjacentClosedPunchExample();
187214
drawFloatPunchExample();
188215
}

0 commit comments

Comments
 (0)