本文整理汇总了C++中ObjList::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjList::push_back方法的具体用法?C++ ObjList::push_back怎么用?C++ ObjList::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjList
的用法示例。
在下文中一共展示了ObjList::push_back方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: perceive
ObjList LifeForm::perceive(double rad){
if (rad>100) rad=100;
if (rad<2) rad=2;
// int i=0;
// assert(i==1);
//
update_position();
SmartPointer<LifeForm> self = SmartPointer<LifeForm>(this);
// cout<<this->species_name();
// cout<<"in perceive"<<endl;
std::vector<SmartPointer<LifeForm>> vector = space.nearby(this->position(), rad);
auto b = vector.begin();
auto e = vector.end();
ObjList info;// = vector
while (b!=e) {
auto in = this->info_about_them(*b);
info.push_back(in);
b++;
}
//energy cost
energy-=perceive_cost(rad);
if (energy<min_energy) {
self->die();
}
return info;
};
示例2: perceive
ObjList LifeForm::perceive(double dist) {
//cout << "perceive" << endl;
ObjList objlist;
if (!is_alive) return objlist;
if (dist < min_perceive_range) dist = min_perceive_range;
if (dist > max_perceive_range) dist = max_perceive_range;
energy -= perceive_cost(dist);
if (energy < min_energy) {
die();
return objlist;
}
std::vector<SmartPointer<LifeForm>> observed_objs = space.nearby(pos,dist);
for (int i = 0; i < observed_objs.size(); i++)
objlist.push_back(info_about_them(observed_objs[i]));
return objlist;
}