本文整理汇总了C++中typenamestd::vector::getSize方法的典型用法代码示例。如果您正苦于以下问题:C++ vector::getSize方法的具体用法?C++ vector::getSize怎么用?C++ vector::getSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类typenamestd::vector
的用法示例。
在下文中一共展示了vector::getSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gridify
void gridify() {
typename std::vector<Element>::iterator i;
SDL_Rect *last = grid.begin()->getSize();
int count = 0;
for (i = grid.begin(); i != grid.end(); i++) {
if (i == grid.begin()) {
i->getSize()->x = position.x;
i->getSize()->y = position.y;
last = i->getSize();
#ifdef DEBUG
std::cout << "First Grid Element: " << i->getSize()->x << " , " << i->getSize()->y << std::endl;
#endif
}
else {
if(count != (gx - 1))
{
i->getSize()->x = last->x + padding;
i->getSize()->y = last->y;
count++;
} else {
count = 0;
i->getSize()->x = position.x;
i->getSize()->y = last->y + padding;
}
last = i->getSize();
}
}
}
示例2: update
void update() {
typename std::vector<Element>::iterator i;
int count = 0;
SDL_Rect * warn_if_same_pos = grid.begin()->getSize();
int warn_count = 0;
for (i = grid.begin(); i != grid.end(); i++) {
#ifndef NO_WARNINGS
if(i->getSize()->x == warn_if_same_pos->x
&&
i->getSize()->y == warn_if_same_pos->y)
{
warn_count++;
}
if(warn_count > 2)
{
printf("Warning!!!! you may be using the same object over and over again!\nuse object * name = new * object(args); in your population routine: gridObject.append(*object); delete name; name = new * object(args);\n");
}
#endif
#ifdef DEBUG
printf("Render[%d]: at (%d,%d)\n",count,i->getSize()->x,i->getSize()->y);
#endif
SDL_RenderCopy(i->getRenderer(), i->getImage(), NULL, i->getSize());
warn_if_same_pos = i->getSize();
count++;
}
}