当前位置: 首页>>代码示例>>C++>>正文


C++ list::height方法代码示例

本文整理汇总了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;
}
开发者ID:danskcarvalho,项目名称:ColorNShapes,代码行数:33,代码来源:Skyline.cpp

示例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;
	}
}
开发者ID:danskcarvalho,项目名称:ColorNShapes,代码行数:29,代码来源:Skyline.cpp


注:本文中的std::list::height方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。