本文整理汇总了C++中std::list::height方法的典型用法代码示例。如果您正苦于以下问题:C++ list::height方法的具体用法?C++ list::height怎么用?C++ list::height使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::list
的用法示例。
在下文中一共展示了list::height方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: packIntoPlace
Rect packIntoPlace(std::list<Vec2>& Skyline, const Vec2& r, std::list<Vec2>::iterator place) {
float x = 0;
auto width = r.width();
//Initialize x
auto first = Skyline.begin();
auto last = Skyline.end();
while (first != last && first != place) {
x += first->width();
first++;
}
auto newHeight = place->height() + r.height();
auto rectangle = newRect(Vec2(x, place->height()), r);
while (place != last && width > 0) {
if (width >= place->width()) {
auto newPlace = Skyline.insert(std::next(place), Vec2(place->width(), newHeight));
Skyline.erase(place);
place = newPlace;
width -= place->width();
}
else { //need to split skyline
Skyline.insert(place, Vec2(width, newHeight));
auto newPlace1 = Skyline.insert(std::next(place), Vec2(place->width() - width, place->height()));
Skyline.erase(place);
place = newPlace1;
width = 0;
}
place++;
}
return rectangle;
}
示例2: computeLostAreas
void computeLostAreas(std::list<Vec2>& Skyline, const Vec2& r, std::list<Vec2>::iterator place, std::vector<Rect>& lostAreas) {
auto baseHeight = place->height();
auto width = r.width();
float x = 0;
lostAreas.clear();
//Initialize x
auto first = Skyline.begin();
auto last = Skyline.end();
while (first != last && first != place) {
x += first->width();
first++;
}
while (place != last) {
if (place->height() < baseHeight) {
auto lostHeight = baseHeight - place->height();
auto lostWidth = width >= place->width() ? place->width() : width;
Rect lostRect = newRect(Vec2(x, place->height()), Vec2(lostWidth, lostHeight));
if (lostRect.width() != 0 && lostRect.height() != 0)
lostAreas.push_back(lostRect);
}
width -= place->width();
x += place->width();
place++;
if (width <= 0)
break;
}
}