本文整理汇总了C++中std::list::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ list::push_back方法的具体用法?C++ list::push_back怎么用?C++ list::push_back使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::list
的用法示例。
在下文中一共展示了list::push_back方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: JustSummoned
void JustSummoned(Creature* pSummon)
{
SummonList.push_back(pSummon->GetGUID());
AggroAllPlayers(pSummon);
}
示例2: DoSummonGrandChampion
void DoSummonGrandChampion(uint32 uiBoss)
{
++uiSummonTimes;
uint32 VEHICLE_TO_SUMMON1 = 0;
uint32 VEHICLE_TO_SUMMON2 = 0;
switch(uiBoss)
{
case 0:
VEHICLE_TO_SUMMON1 = VEHICLE_MOKRA_SKILLCRUSHER_MOUNT;
VEHICLE_TO_SUMMON2 = VEHICLE_ORGRIMMAR_WOLF;
break;
case 1:
VEHICLE_TO_SUMMON1 = VEHICLE_ERESSEA_DAWNSINGER_MOUNT;
VEHICLE_TO_SUMMON2 = VEHICLE_SILVERMOON_HAWKSTRIDER;
break;
case 2:
VEHICLE_TO_SUMMON1 = VEHICLE_RUNOK_WILDMANE_MOUNT;
VEHICLE_TO_SUMMON2 = VEHICLE_THUNDER_BLUFF_KODO;
break;
case 3:
VEHICLE_TO_SUMMON1 = VEHICLE_ZUL_TORE_MOUNT;
VEHICLE_TO_SUMMON2 = VEHICLE_DARKSPEAR_RAPTOR;
break;
case 4:
VEHICLE_TO_SUMMON1 = VEHICLE_DEATHSTALKER_VESCERI_MOUNT;
VEHICLE_TO_SUMMON2 = VEHICLE_FORSAKE_WARHORSE;
break;
default:
return;
}
if (Creature* pBoss = me->SummonCreature(VEHICLE_TO_SUMMON1,SpawnPosition))
{
switch(uiSummonTimes)
{
case 1:
{
uiVehicle1GUID = pBoss->GetGUID();
uint64 uiGrandChampionBoss1 = 0;
if (Creature* pBoss = Unit::GetCreature(*me, uiVehicle1GUID))
if (Vehicle* pVehicle = pBoss->GetVehicleKit())
if (Unit* pUnit = pVehicle->GetPassenger(0))
uiGrandChampionBoss1 = pUnit->GetGUID();
if (pInstance)
{
pInstance->SetData64(DATA_GRAND_CHAMPION_VEHICLE_1,uiVehicle1GUID);
pInstance->SetData64(DATA_GRAND_CHAMPION_1,uiGrandChampionBoss1);
}
pBoss->AI()->SetData(1,0);
break;
}
case 2:
{
uiVehicle2GUID = pBoss->GetGUID();
uint64 uiGrandChampionBoss2 = 0;
if (Creature* pBoss = Unit::GetCreature(*me, uiVehicle2GUID))
if (Vehicle* pVehicle = pBoss->GetVehicleKit())
if (Unit* pUnit = pVehicle->GetPassenger(0))
uiGrandChampionBoss2 = pUnit->GetGUID();
if (pInstance)
{
pInstance->SetData64(DATA_GRAND_CHAMPION_VEHICLE_2,uiVehicle2GUID);
pInstance->SetData64(DATA_GRAND_CHAMPION_2,uiGrandChampionBoss2);
}
pBoss->AI()->SetData(2,0);
break;
}
case 3:
{
uiVehicle3GUID = pBoss->GetGUID();
uint64 uiGrandChampionBoss3 = 0;
if (Creature* pBoss = Unit::GetCreature(*me, uiVehicle3GUID))
if (Vehicle* pVehicle = pBoss->GetVehicleKit())
if (Unit* pUnit = pVehicle->GetPassenger(0))
uiGrandChampionBoss3 = pUnit->GetGUID();
if (pInstance)
{
pInstance->SetData64(DATA_GRAND_CHAMPION_VEHICLE_3,uiVehicle3GUID);
pInstance->SetData64(DATA_GRAND_CHAMPION_3,uiGrandChampionBoss3);
}
pBoss->AI()->SetData(3,0);
break;
}
default:
return;
}
for (uint8 i = 0; i < 3; ++i)
{
if (Creature* pAdd = me->SummonCreature(VEHICLE_TO_SUMMON2,SpawnPosition,TEMPSUMMON_CORPSE_DESPAWN))
{
switch(uiSummonTimes)
{
case 1:
Champion1List.push_back(pAdd->GetGUID());
break;
case 2:
Champion2List.push_back(pAdd->GetGUID());
break;
case 3:
//.........这里部分代码省略.........
示例3: MarkDirty
void Inventory::MarkDirty(ItemInst *inst) {
if(inst) {
dirty_inst.push_back(inst);
}
}
示例4: processTree
void processTree() {
TriSet::iterator tit;
ClassMap::iterator cit, cit2;
int c, cOld;
NTriangulation* t;
for (NPacket* p = tree; p; p = p->nextTreePacket())
if (p->type() == PACKET_TRIANGULATION) {
// A triangulation to process.
t = static_cast<NTriangulation*>(p);
fprintf(stderr, "Processing %s ...\n", t->label().c_str());
nTris++;
nonMin = false;
orig = static_cast<NTriangulation*>(p);
equivs.clear();
equivs.insert(orig);
tryMovesUp(orig, argUp);
if (nonMin) {
allNonMin.push_back(orig);
nNonMin++;
continue;
}
// In equivs we now have a list of all triangulations
// equivalent to orig.
// Is this an equivalence class we're already seen?
for (tit = equivs.begin(); tit != equivs.end(); tit++) {
cit = eClass.find(*tit);
if (cit != eClass.end())
break;
}
if (tit != equivs.end()) {
// We found an equivalence class. Insert everything we
// haven't seen yet, and merge the classes of everything
// we have.
c = cit->second;
for (tit = equivs.begin(); tit != equivs.end(); tit++) {
cit = eClass.find(*tit);
if (cit == eClass.end())
eClass.insert(std::make_pair(*tit, c));
else if (cit->second != c) {
// Merge the two equivalence classes.
cOld = cit->second;
for (cit = eClass.begin(); cit != eClass.end(); cit++)
if (cit->second == cOld)
cit->second = c;
nClasses--;
}
}
} else {
// No such equivalence class. Insert everything.
c = nextClass++;
for (tit = equivs.begin(); tit != equivs.end(); tit++)
eClass.insert(std::make_pair(*tit, c));
nClasses++;
}
}
// Finished progress reporting.
fprintf(stderr, "\n");
// Write the summary of results.
if (! allNonMin.empty()) {
printf("NON-MINIMAL TRIANGULATIONS:\n\n");
for (std::list<NTriangulation*>::const_iterator it = allNonMin.begin();
it != allNonMin.end(); it++)
printf(" %s\n", (*it)->label().c_str());
printf("\n");
}
if (nClasses) {
printf("EQUIVALENCE CLASSES:\n\n");
if (outFile) {
newTree = new NContainer();
newTree->setLabel("Equivalence Classes");
}
int classNum = 1;
std::string className;
NContainer* classCnt = 0;
for (cit = eClass.begin(); cit != eClass.end(); cit++)
if (cit->second >= 0) {
// The first triangulation of a new equivalence class.
c = cit->second;
std::ostringstream s;
s << "Class " << classNum << " : " <<
cit->first->homology().str();
className = s.str();
classNum++;
printf("%s\n\n", className.c_str());
if (outFile) {
classCnt = new NContainer();
//.........这里部分代码省略.........
示例5: SetGUID
void SetGUID(uint64 const guid, int32 id/* = 0 */)
{
if (id == DATA_INTENSE_COLD)
intenseColdList.push_back(guid);
}
示例6: fixupParamsSub
void RTLInstDict::fixupParamsSub( std::string s, std::list<std::string>& funcParams, bool& haveCount, int mark )
{
ParamEntry ¶m = DetParamMap[s];
if ( param.params.size() == 0 )
{
std::cerr << "Error in SSL File: Variant operand " << s << " has no branches. Well that's really useful...\n";
return;
}
if ( param.mark == mark )
return; /* Already seen this round. May indicate a cycle, but may not */
param.mark = mark;
for ( std::list<std::string>::iterator it = param.params.begin();
it != param.params.end(); it++ )
{
ParamEntry &sub = DetParamMap[*it];
if (sub.kind == PARAM_VARIANT )
{
fixupParamsSub(*it, funcParams, haveCount, mark );
if (!haveCount)
{ /* Empty branch? */
continue;
}
}
else if (!haveCount )
{
haveCount = true;
char buf[10];
for (unsigned i=1; i <= sub.funcParams.size(); i++ )
{
sprintf( buf, "__lp%d", i );
funcParams.push_back(buf);
}
}
if (funcParams.size() != sub.funcParams.size() )
{
std::cerr << "Error in SSL File: Variant operand " << s << " does not have a fixed number of functional "
"parameters:\n" << "Expected " << funcParams.size() << ", but branch " << *it << " has " <<
sub.funcParams.size() << ".\n";
}
else if (funcParams != sub.funcParams && sub.asgn != NULL )
{
/* Rename so all the parameter names match */
std::list<std::string>::iterator i,j;
for ( i = funcParams.begin(), j = sub.funcParams.begin(); i != funcParams.end(); i++, j++ )
{
Exp* match = Location::param(j->c_str());
Exp* replace = Location::param(i->c_str());
sub.asgn->searchAndReplace( match, replace );
}
sub.funcParams = funcParams;
}
}
// if( param.funcParams.size() != funcParams.size() )
// theSemTable.setItem( n, cFUNCTION, 0, 0, funcParams.size(),
// theSemTable[n].sName.c_str() );
param.funcParams = funcParams;
}
示例7: SetTarget
void SetTarget(std::list<WorldObject*>& targets)
{
targets.clear();
if (_target)
targets.push_back(_target);
}
示例8: cnx_dolink
void cnx_dolink(bt_session_cnx_t *cnx) throw() { cnx_db.push_back(cnx); }
示例9: JustSummoned
void JustSummoned(Creature* summoned)
{
lDwarfGUIDList.push_back(summoned->GetGUID());
summoned->AddThreat(me, 0.0f);
summoned->AI()->AttackStart(me);
}
示例10: new_line
void LineAccumulator::new_line()
{
//std::cerr << "NEW LINE" << std::endl;
Line line;
m_lines.push_back(line);
}
示例11: swarm_dolink
void swarm_dolink(bt_swarm_t *swarm) throw() { swarm_db.push_back(swarm); }
示例12: PathFind
//.........这里部分代码省略.........
}
if (!CanWalk(nSX, nSY) || !CanWalk(nEX, nEY))
{
return -3;
}
m_uSearchVersion++;
ASTAR_NODE* pNode = GetNode(nSX, nSY);
ASTAR_NODE* pEnd = GetNode(nEX, nEY);
if (pNode == NULL || pEnd == NULL)
{
return -4;
}
m_OpenedList.Clear();
pNode->bOpened = true;
m_OpenedList.Push(pNode);
static int tDir[8][2] = { { -1, 1 }, { -1, 0 }, { -1, -1 }, { 0, 1 }, { 0, -1 }, { 1, 1 }, { 1, 0 }, { 1, -1 } };
while (!pEnd->bClosed && m_OpenedList.Size() > 0)
{
pNode = m_OpenedList.Min();
m_OpenedList.Remove(pNode);
pNode->bOpened = false;
pNode->bClosed = true;
ASTAR_NODE* pTmpNode = NULL;
for (int i = 0; i < 8; i++)
{
int nX = pNode->nX + tDir[i][0];
int nY = pNode->nY + tDir[i][1];
pTmpNode = GetNode(nX, nY);
if (pTmpNode == NULL || !CanWalk(nX, nY))
{
continue;
}
if (!CanDiagonalWalk(pNode, pTmpNode))
{
continue;
}
int nG = pNode->nG + GetG(pNode->nX, pNode->nY, pTmpNode->nX, pTmpNode->nY);
int nH = GetH(pTmpNode->nX, pTmpNode->nY, pEnd->nX, pEnd->nY);
int nF = nG + nH;
if (pTmpNode->bOpened || pTmpNode->bClosed)
{
if (pTmpNode->nKey > nF)
{
pTmpNode->nG = nG;
pTmpNode->nH = nH;
pTmpNode->nKey = nF;
pTmpNode->pParent = pNode;
if (pTmpNode->bOpened)
{
m_OpenedList.Update(pTmpNode);
}
}
}
else
{
pTmpNode->nG = nG;
pTmpNode->nH = nH;
pTmpNode->nKey = nF;
pTmpNode->pParent = pNode;
m_OpenedList.Push(pTmpNode);
pTmpNode->bOpened = true;
}
}
}
if (!pEnd->bClosed)
{
return -5;
}
m_oTmpListPath.clear();
ASTAR_NODE* pTarNode = pNode;
//XLog(LEVEL_DEBUG,"Robot path0:");
while (pTarNode != NULL)
{
ASTAR_POINT oASPos;
oASPos.nX = pTarNode->nX;
oASPos.nY = pTarNode->nY;
//XLog(LEVEL_DEBUG, "[%d,%d] ", oASPos.nX, 35 - oASPos.nY);
m_oTmpListPath.push_front(oASPos);
pTarNode = pTarNode->pParent;
}
//XLog(LEVEL_DEBUG,"\n");
if (m_oTmpListPath.size() > 2)
{
Floyd(m_oTmpListPath);
}
ASLITER iter = m_oTmpListPath.begin();
ASLITER iter_end = m_oTmpListPath.end();
//XLog(LEVEL_DEBUG,"Robot path1:");
for (; iter != iter_end; iter++)
{
ASTAR_POINT& oPos = *iter;
int nPosX = (int)((oPos.nX + 0.5f) * gnUnitWidth);
int nPosY = (int)((oPos.nY + 0.5f) * gnUnitHeight);
oListPath.push_back(Point(nPosX, nPosY));
//XLog(LEVEL_DEBUG,"[%d,%d](%d,%d) ", nPosX, nPosY, oPos.nX, 35-oPos.nY);
}
//XLog(LEVEL_DEBUG,"\n");
return 0;
}
示例13: target_types
void
StatsD::ParseMetrics( std::string const &stats_metrics_string, char const *param_name, std::list< classad::ClassAd * > &stats_metrics ) {
// Parse a list of metrics. The expected syntax is
// a list of ClassAds, optionally delimited by commas and or
// whitespace.
int offset = 0;
while(1) {
if(offset >= (int)stats_metrics_string.size()) break;
int this_offset = offset; //save offset before eating an ad.
std::string error_msg;
classad::ClassAdParser parser;
classad::ClassAd *ad = new classad::ClassAd;
bool failed = false;
if(!parser.ParseClassAd(stats_metrics_string,*ad,offset)) {
int final_offset = this_offset;
std::string final_stats_metrics_string = stats_metrics_string;
final_stats_metrics_string += "\n[]"; // add an empty ClassAd
if(parser.ParseClassAd(final_stats_metrics_string,*ad,final_offset)) {
// There must have been some trailing whitespace or
// comments after the last ClassAd, so the only reason
// ParseClassAd() failed was because there was no ad.
// Therefore, we are done.
delete ad;
break;
}
failed = true;
}
if( failed ) {
EXCEPT("CONFIGURATION ERROR: error in metrics defined in %s: %s, for entry starting here: %.80s\n",
param_name,error_msg.c_str(),stats_metrics_string.c_str() + this_offset);
}
classad::ClassAd *ad2 = new ClassAd(m_default_metric_ad);
ad2->Update(*ad);
delete ad;
ad = ad2;
int verbosity = 0;
ad->EvaluateAttrInt(ATTR_VERBOSITY,verbosity);
if( verbosity > m_verbosity ) {
delete ad;
continue;
}
// for efficient queries to the collector, keep track of
// which type of ads we need
std::string target_type;
ad->EvaluateAttrString(ATTR_TARGET_TYPE,target_type);
if( target_type.empty() ) {
classad::ClassAdUnParser unparser;
std::string ad_str;
unparser.Unparse(ad_str,ad);
EXCEPT("CONFIGURATION ERROR: no target type specified for metric defined in %s: %s\n",
param_name,
ad_str.c_str());
}
StringList target_types(target_type.c_str());
m_target_types.create_union(target_types,true);
stats_metrics.push_back(ad);
}
}
示例14: expandTemplate
void TemplateSimplifier::expandTemplate(
TokenList& tokenlist,
const Token *tok,
const std::string &name,
std::vector<const Token *> &typeParametersInDeclaration,
const std::string &newName,
std::vector<const Token *> &typesUsedInTemplateInstantiation,
std::list<Token *> &templateInstantiations)
{
for (const Token *tok3 = tokenlist.front(); tok3; tok3 = tok3->next()) {
if (tok3->str() == "{" || tok3->str() == "(" || tok3->str() == "[")
tok3 = tok3->link();
// Start of template..
if (tok3 == tok) {
tok3 = tok3->next();
}
// member function implemented outside class definition
else if (TemplateSimplifier::instantiateMatch(tok3, name, typeParametersInDeclaration.size(), ":: ~| %var% (")) {
tokenlist.addtoken(newName.c_str(), tok3->linenr(), tok3->fileIndex());
while (tok3->str() != "::")
tok3 = tok3->next();
}
// not part of template.. go on to next token
else
continue;
int indentlevel = 0;
std::stack<Token *> brackets; // holds "(", "[" and "{" tokens
for (; tok3; tok3 = tok3->next()) {
if (tok3->isName()) {
// search for this token in the type vector
unsigned int itype = 0;
while (itype < typeParametersInDeclaration.size() && typeParametersInDeclaration[itype]->str() != tok3->str())
++itype;
// replace type with given type..
if (itype < typeParametersInDeclaration.size()) {
unsigned int typeindentlevel = 0;
for (const Token *typetok = typesUsedInTemplateInstantiation[itype];
typetok && (typeindentlevel>0 || !Token::Match(typetok, ",|>|>>"));
typetok = typetok->next()) {
if (Token::Match(typetok, "%var% <") && templateParameters(typetok->next()) > 0)
++typeindentlevel;
else if (typeindentlevel > 0 && typetok->str() == ">")
--typeindentlevel;
else if (typeindentlevel > 0 && typetok->str() == ">>") {
if (typeindentlevel == 1)
break;
typeindentlevel -= 2;
}
tokenlist.addtoken(typetok, tok3->linenr(), tok3->fileIndex());
}
continue;
}
}
// replace name..
if (Token::Match(tok3, (name + " !!<").c_str())) {
tokenlist.addtoken(newName.c_str(), tok3->linenr(), tok3->fileIndex());
continue;
}
// copy
tokenlist.addtoken(tok3, tok3->linenr(), tok3->fileIndex());
if (Token::Match(tok3, "%type% <")) {
//if (!Token::simpleMatch(tok3, (name + " <").c_str()))
//done = false;
templateInstantiations.push_back(tokenlist.back());
}
// link() newly tokens manually
else if (tok3->str() == "{") {
brackets.push(tokenlist.back());
indentlevel++;
} else if (tok3->str() == "(") {
brackets.push(tokenlist.back());
} else if (tok3->str() == "[") {
brackets.push(tokenlist.back());
} else if (tok3->str() == "}") {
assert(brackets.empty() == false && brackets.top()->str() == "{");
Token::createMutualLinks(brackets.top(), tokenlist.back());
brackets.pop();
if (indentlevel <= 1 && brackets.empty()) {
// there is a bug if indentlevel is 0
// the "}" token should only be added if indentlevel is 1 but I add it always intentionally
// if indentlevel ever becomes 0, cppcheck will write:
// ### Error: Invalid number of character {
break;
}
--indentlevel;
} else if (tok3->str() == ")") {
assert(brackets.empty() == false && brackets.top()->str() == "(");
Token::createMutualLinks(brackets.top(), tokenlist.back());
brackets.pop();
} else if (tok3->str() == "]") {
assert(brackets.empty() == false && brackets.top()->str() == "[");
//.........这里部分代码省略.........
示例15: detectFaces
// return number of faces and score
void detectFaces(const CxImage& img, std::list <Face>& lFaces, int nRot)
{
if (cascade_el == NULL || cascade_er == NULL || cascade_f == NULL || cascade_m == NULL || cascade_n == NULL)
init();
CxImage imgRotated (img);
imgRotated.Rotate180();
IplImage *pIplImage = cvCreateImageHeader (cvSize (img.GetWidth(), img.GetHeight()), 8, img.GetBpp() / 8);
pIplImage->imageDataOrigin = (char*)imgRotated.GetDIB();
pIplImage->imageData = (char*)imgRotated.GetBits();
CvMemStorage *storage;
/* setup memory storage, needed by the object detector */
storage = cvCreateMemStorage(0);
assert(cascade_f && cascade_el && cascade_er && cascade_m && cascade_n && storage);
/* haar detection for faces */
CvSeq *pFaces = cvHaarDetectObjects(
pIplImage, cascade_f, storage,
1.2, 2, CV_HAAR_DO_CANNY_PRUNING, cvSize( 40, 40 ) );
if (pFaces->total == 0)
return;
CvSeq seqFaces (*pFaces);
list <CvRect> lrFaces;
for(int idxFace = 0; idxFace < seqFaces.total; idxFace++ ) {
CvRect *r = (CvRect*)cvGetSeqElem(&seqFaces, idxFace);
if (r)
lrFaces.push_back (*r);
}
/* haar detection for eyes */
list<pair <RECT, RECT>> lpairEyes;
detect_eyes (storage, pIplImage, lpairEyes);
/* haar detection for mouths */
list<RECT> lMouths;
detect_mouths (storage, pIplImage, lMouths);
/* haar detection for noses */
list<RECT> lNoses;
detect_noses (storage, pIplImage, lNoses);
for(list <CvRect>::iterator itFace = lrFaces.begin(); itFace != lrFaces.end(); ++itFace) {
CvRect r (*itFace);
CvRect rFace (*itFace);
rFace.x = img.GetWidth() - r.x - r.width;
rFace.y = img.GetHeight() - r.y - r.height;
RECT rcFace;
rcFace.left = img.GetWidth() - r.x - r.width - 10; rcFace.right = img.GetWidth() - r.x + 10;
rcFace.top = img.GetHeight() - r.y - r.height - 10; rcFace.bottom = img.GetHeight() - r.y + 10;
/* detect current eyes */
pair <RECT, RECT> pairEyes;
match_eyes_with_face (lpairEyes, rFace, pairEyes);
/* detect current mouth */
RECT rcMouth;
match_mouths_with_face (lMouths, rFace, pairEyes, rcMouth);
/* detect current nose */
RECT rcNose;
match_noses_with_face (lNoses, rFace, pairEyes, rcMouth, rcNose);
lFaces.push_back (Face (rcFace, pairEyes, rcMouth, rcNose, nRot));
}
Face::adjustRectFaces(lFaces);
cvReleaseMemStorage (&storage);
cvReleaseImageHeader (&pIplImage);
}