本文整理汇总了C++中AVL::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ AVL::Add方法的具体用法?C++ AVL::Add怎么用?C++ AVL::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AVL
的用法示例。
在下文中一共展示了AVL::Add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main( void ) {
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
AVL<segment> Tree;
int n;
cin >> n;
vector<segment> seg;
for (int i = 0; i < n; i++) {
point pointOne, pointTwo;
cin >> pointOne.x >> pointOne.y >> pointTwo.x >> pointTwo.y;
seg.push_back(segment(pointOne, pointTwo));
}
vector<point_event> e;
for (int i = 0; i < n; i++) {
e.push_back(point_event(min(seg[i].pointOne.x, seg[i].pointTwo.x), 1, i));
e.push_back(point_event(max(seg[i].pointOne.x, seg[i].pointTwo.x), -1, i));
}
sort(e.begin(), e.end());
double val = numeric_limits<double>::max();
segment zero(point(val, val), point(val, val));
for (int i = 0; i < e.size(); i++) {
int ind = e[i].ind;
if (e[i].type == 1) {
Tree.Add(seg[ind]);
segment cur = Tree.Next(seg[ind]);
if (!(cur == zero) && crossing(cur, seg[ind])) {
cout << "Еть пересечение";
return 0;
}
cur = Tree.Prev(seg[ind]);
if (!(cur == zero) && crossing(cur, seg[ind])) {
cout << "Есть пересечиние";
return 0;
}
}
else {
segment cur = Tree.Next(seg[ind]);
if (!(cur == zero) && crossing(cur, seg[ind])) {
cout << "Еть пересечение";
return 0;
}
cur = Tree.Prev(seg[ind]);
if (!(cur == zero) && crossing(cur, seg[ind])) {
cout << "Есть пересечиние";
return 0;
}
Tree.Delete(seg[ind]);
}
}
cout << "Нет пересечений";
return 0;
}