46 cout <<
"=== Meeting Scheduler ===" << endl;
55 calendar.
insert(960, 1020);
57 cout <<
"Existing meetings:" << endl;
59 cout <<
" [" << iv.
low / 60 <<
":"
60 << (iv.
low % 60 < 10 ?
"0" :
"") << iv.
low % 60
61 <<
" - " << iv.
high / 60 <<
":"
62 << (iv.
high % 60 < 10 ?
"0" :
"") << iv.
high % 60
68 cout <<
"\nProposed meeting: 14:00 - 15:00" << endl;
71 if (conflicts.is_empty())
72 cout <<
" No conflicts! Meeting can be scheduled." << endl;
75 cout <<
" Conflicts with:" << endl;
77 cout <<
" [" << iv.
low / 60 <<
":"
78 << (iv.
low % 60 < 10 ?
"0" :
"") << iv.
low % 60
79 <<
" - " << iv.
high / 60 <<
":"
80 << (iv.
high % 60 < 10 ?
"0" :
"") << iv.
high % 60
86 cout <<
"\nStabbing query: what meetings are at 14:30?" << endl;
89 cout <<
" [" << iv.
low / 60 <<
":"
90 << (iv.
low % 60 < 10 ?
"0" :
"") << iv.
low % 60
91 <<
" - " << iv.
high / 60 <<
":"
92 << (iv.
high % 60 < 10 ?
"0" :
"") << iv.
high % 60
100 cout <<
"\n=== 1D Segment Intersection ===" << endl;
121 cout <<
"Segments:" << endl;
122 for (
const auto & s : segments)
124 <<
" x=[" << s.x_range.low <<
", " << s.x_range.high <<
"]"
130 for (
const auto & seg : segments)
133 if (not overlaps.is_empty())
135 cout <<
"\nSegment y=" << seg.y
136 <<
" x=[" << seg.x_range.low <<
"," << seg.x_range.high
137 <<
"] shares x-range with:" << endl;
139 cout <<
" x=[" << iv.
low <<
", " << iv.
high <<
"]" << endl;
145 cout <<
"\nTree verified: " << (active.
verify() ?
"yes" :
"no") << endl;
High-level interval tree with automatic memory management.
DynList< Key > find_all_overlaps(const Key &query) const
Find all overlapping intervals.
DynList< Key > find_stab(const T &p) const
Find all intervals containing point p.
Key & insert_dup(const Key &iv)
Insert interval, allowing duplicates.
Key & insert(const Key &iv)
Insert an interval (unique).
bool verify() const
Verify all tree invariants (BST, Treap, MaxEndpoint).
Represents a line segment between two points.
void for_each(Operation &operation) const
Traverse all the container and performs an operation on each element.
void segment_intersection()
Scenario 2: 1D segment intersection.
void meeting_scheduler()
Scenario 1: Meeting scheduler — detect conflicts.
Main namespace for Aleph-w library functions.
Closed interval [low, high].
Interval tree: augmented BST for overlap/stabbing queries.