本文整理汇总了C++中pair函数的典型用法代码示例。如果您正苦于以下问题:C++ pair函数的具体用法?C++ pair怎么用?C++ pair使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pair函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pair
void hyjalAI::HideNearPos(float x, float y)
{
CellCoord pair(Trinity::ComputeCellCoord(x, y));
Cell cell(pair);
cell.SetNoCreate();
// First get all creatures.
std::list<Creature*> creatures;
Trinity::AllFriendlyCreaturesInGrid creature_check(me);
Trinity::CreatureListSearcher<Trinity::AllFriendlyCreaturesInGrid> creature_searcher(me, creatures, creature_check);
TypeContainerVisitor <Trinity::CreatureListSearcher<Trinity::AllFriendlyCreaturesInGrid>, GridTypeMapContainer> creature_visitor(creature_searcher);
cell.Visit(pair, creature_visitor, *(me->GetMap()), *me, me->GetGridActivationRange());
if (!creatures.empty())
{
for (std::list<Creature*>::const_iterator itr = creatures.begin(); itr != creatures.end(); ++itr)
{
(*itr)->SetVisible(false);
(*itr)->setFaction(35);//make them friendly so mobs won't attack them
}
}
}
示例2: file
void BanPair::loadBanPairs(){
// special cases
AllBanSet << "shencaocao" << "dongzhuo" << "zuoci" << "zhoutai";
SecondBanSet << "jiangboyue" << "luboyan";
QFile file(BanPairFilename);
if(file.open(QIODevice::ReadOnly)){
QTextStream stream(&file);
while(!stream.atEnd()){
QString line = stream.readLine();
QStringList names = line.split(" ");
if(names.length() != 2)
continue;
QString first = names.at(0);
QString second = names.at(1);
BanPair pair(first, second);
BanPairSet.insert(pair);
}
}
}
示例3: JustStartedEscort
void JustStartedEscort()
{
m_uiEventTimer = 5000;
m_uiEventCount = 0;
m_lResearchersList.clear();
float x, y, z;
me->GetPosition(x, y, z);
CellPair pair(Trinity::ComputeCellPair(x, y));
Cell cell(pair);
cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
Trinity::AllCreaturesOfEntryInRange check(me, NPC_RESEARCHER, 25);
Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange> searcher(me,m_lResearchersList, check);
TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange>, GridTypeMapContainer> cSearcher(searcher);
cell.Visit(pair, cSearcher, *(me->GetMap()));
if (!m_lResearchersList.empty())
SetFormation();
}
示例4: doTest
void doTest(const Vector<S32> &loadoutZoneCount, S32 neutralLoadoutZoneCount, S32 hostileLoadoutZoneCount, const Vector<S32> &results)
{
ASSERT_EQ(loadoutZoneCount.size(), results.size()) << "Malformed test!"; // Sanity check
string level = getLevelWithVariableNumberOfLoadoutZones(loadoutZoneCount, neutralLoadoutZoneCount, hostileLoadoutZoneCount);
GamePair pair(level);
ClientGame *client = pair.getClient(0);
ServerGame *server = pair.server;
for(S32 i = 0; i < results.size(); i++)
if(results[i])
{
EXPECT_TRUE(client->levelHasLoadoutZoneForTeam(i));
EXPECT_TRUE(server->levelHasLoadoutZoneForTeam(i));
}
else
{
EXPECT_FALSE(client->levelHasLoadoutZoneForTeam(i));
EXPECT_FALSE(server->levelHasLoadoutZoneForTeam(i));
}
}
示例5: foreach
void BanPair::loadBanPairs(){
// special cases
QStringList banlist = Config.value("Banlist/Pairs","").toStringList();
foreach(QString line, banlist){
QStringList names = line.split("+");
if(names.isEmpty())
continue;
QString first = names.at(0).trimmed();
if(names.length() == 2){
QString second = names.at(1).trimmed();
if(first.isEmpty())
SecondBanSet.insert(second);
else{
BanPair pair(first, second);
BanPairSet.insert(pair);
}
}
else if(names.length()==1){
AllBanSet.insert(first);
}
}
示例6: logStr
void UninstallAllThread::removeUninstallInfo()
{
gcString logStr("{0}\n", Managers::GetString("#DUN_THREAD_UNINSTALL"));
onLogEvent(logStr);
m_iTotalPos++;
std::pair<uint32,uint32> pair(m_iTotalPos*100/m_iTotal, 0);
onProgressEvent(pair);
std::vector<std::string> regKeys;
UTIL::WIN::getAllRegKeys("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall", regKeys);
for (size_t x=0; x<regKeys.size(); x++)
{
std::string key = regKeys[x];
if (key.find("Desura") != 0)
continue;
gcString regKey("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{0}", key);
UTIL::WIN::delRegTree(regKey.c_str());
}
}
示例7: TGraphSymbol
TGraphSymbol* TDependencyGraph::getOrCreateSymbol(TIntermSymbol* intermSymbol)
{
TSymbolIdMap::const_iterator iter = mSymbolIdMap.find(intermSymbol->getId());
TGraphSymbol* symbol = NULL;
if (iter != mSymbolIdMap.end()) {
TSymbolIdPair pair = *iter;
symbol = pair.second;
} else {
symbol = new TGraphSymbol(intermSymbol);
mAllNodes.push_back(symbol);
TSymbolIdPair pair(intermSymbol->getId(), symbol);
mSymbolIdMap.insert(pair);
// We save all sampler symbols in a collection, so we can start graph traversals from them quickly.
if (IsSampler(intermSymbol->getBasicType()))
mSamplerSymbols.push_back(symbol);
}
return symbol;
}
示例8: strategy
int strategy(const int hd[], const int fd[], int cg, int tk, const int ud[], int us)
{
int disc_num; // 捨てるカードの番号(-1:捨てない)
int t;
int k, k1, k2; // 反復変数
Handcard hands[5]; // 手札を保管
Cards hand_card, deck_card, remain_card;
// 手札の情報を格納
for (k1 = 0; k1 < HNUM; k1++ ) {
hands[k1].num_val = hd[k1];
hands[k1].num = hd[k1] % 13;
hands[k1].sut = hd[k1] / 13;
hands[k1].pos = k1;
for ( k2 = 0; k2 < 11; k2++ ) { hands[k1].exp[k2] = 0; }
}
calc_card(hands, &remain_card, &deck_card, &hand_card, ud, us);
//フルハウス以上は確定
if ( tk != 5 && poker_point(hd) >= P6 ) { return -1; }
disc_num = limit_take(cg, tk, hands, remain_card, hand_card, deck_card, hd); if ( disc_num != DEFAULT_NUM ) { return disc_num; }
// ストレートリーチならストレートを狙う
if ( check_straight(remain_card, hand_card) >= 1 ) {
return straight(hands, remain_card, hand_card, deck_card, cg);
}
// フラッシュリーチならフラッシュを狙う
for (k1 = 0; k1 < HNUM; k1++ ) {
if ( hand_card.sut[k1] >= 4 && deck_card.sut[k1] >= 2 ) {
return flush(hands, hand_card, deck_card, cg);
}
}
/* // 3カード以上ならペア系を狙う */
if ( poker_point_pair(hand_card.num) == P3 ) {
return pair(hands, hand_card, deck_card, remain_card);
}
return decide_discard(hands, remain_card, hand_card, deck_card, cg, tk);
}
示例9: Scope
Scope& Scope::AppendScope(const std::string& key)
{
if (key == std::string())
throw std::exception("Key cannot be an empty string.");
Scope* newScope = new Scope();
newScope->mParent = this;
// try to find entry first in this scope
Datum* d = Find(key);
if (d != nullptr)
{
if (d->GetType() != Datum::Table && d->GetType() != Datum::Unknown)
{
delete newScope;
throw std::exception("Found entry is not a table!");
}
if (d->IsExternal())
{
delete newScope;
throw std::exception("Table entry is external. Cannot modify data owned by something else.");
}
// a new scope gets added into this table datum
std::uint32_t datumSize = d->Size();
d->Set(newScope, datumSize);
return *d->GetTable(datumSize);
}
// if no entry is found, create new datum with this scope
Datum scopeDatum;
scopeDatum = newScope;
std::pair<std::string, Datum> pair(key, scopeDatum);
HashMap<std::string, Datum>::Iterator iterator = mTable.Insert(pair);
mOrder.PushBack(&(*iterator));
return *(iterator->second.GetTable());
}
示例10: Boom
void Boom()
{
std::list<Creature*> templist;
float x, y, z;
me->GetPosition(x, y, z);
{
CellCoord pair(Trinity::ComputeCellCoord(x, y));
Cell cell(pair);
cell.SetNoCreate();
Trinity::AllCreaturesOfEntryInRange check(me, NPC_FIRE_BOMB, 100);
Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange> searcher(me, templist, check);
TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange>, GridTypeMapContainer> cSearcher(searcher);
cell.Visit(pair, cSearcher, *me->GetMap(), *me, me->GetGridActivationRange());
}
for (std::list<Creature*>::const_iterator i = templist.begin(); i != templist.end(); ++i)
{
(*i)->CastSpell(*i, SPELL_FIRE_BOMB_DAMAGE, true);
(*i)->RemoveAllAuras();
}
}
示例11: collision_dectect
bool squares::collision_dectect(vector<dynamic_info> status)
{
position=current_body(status);
vector<pair> vp;//=bound_box_detect();
for(int i=0;i<(int)vp.size();i++)
cout<<vp[i].a<<" "<<vp[i].b<<endl;
bool collision=false;
collision_pair.clear();
for(int i=0;i<(int)status.size();i++)
{
for(int j=i+1;j<(int)status.size();j++)
{
if(squares_collision(i,j,status[i].x,status[j].x))
{
collision_pair.push_back(pair(i,j));
collision=true;
}
}
}
return collision;
}
示例12: map
static int
map(rconlexer* lexer, rconnode** nodep, int optional)
{
rconnode* node = NULL;
rconnode* subnode = NULL;
struct rconlist list = {NULL,0,0};
int token;
ENTER(_map);
node = createrconnode(lexer,rcon_map);
for(;;) {
token = nexttoken(lexer);
if(optional && token == RBRACE)
FAIL(lexer,"brace mismatch");
else if(optional && token == EOF) goto done;
else if(!optional && token == EOF)
FAIL(lexer,"unclosed map");
else if(!optional && token == RBRACE) goto done;
if(token == COMMA || token == SEMICOLON) continue;
pushtoken(lexer);
if(!pair(lexer,&subnode)) goto fail;
if(!listadd(&list,subnode)) goto fail;
}
done:
node->list.values = list.contents;
node->list.nvalues = list.len;
if(nodep) *nodep = node;
LEAVE(_map,1);
return 1;
fail:
listclear(&list);
if(subnode != NULL) rconnodefree(subnode);
if(node != NULL) rconnodefree(node);
LEAVE(_map,0);
return 0;
}
示例13: pair
/* Brief: TODO description
* Parameter: index, TODO description
* Parameter: value, TODO description
* Parameter: role, TODO description
*/
bool CDailyWeatherModel::setData( const QModelIndex & index, const QVariant & value, int role )
{
int column = index.column();
int row = index.row();
Hash* hash = mStation->getWeather();
QString yr = QString::number(mYear);
QString doy = QString::number(row+1);
Pair pair(yr, doy);
// Find item in weather map with key
Hash::iterator iter = hash->find(pair);
QVector<QString>* values = iter.value();
if (index.isValid() && role == Qt::EditRole)
{
(*values)[column-2] = value.toString();
emit dataChanged(index, index);
return true;
}
return false;
}
示例14: findBoundingBoxes
std::vector<std::pair<CvPoint, CvPoint> > findBoundingBoxes(
std::vector<std::vector<Point2d> > & components, IplImage * output) {
std::vector<std::pair<CvPoint, CvPoint> > bb;
bb.reserve(components.size());
for (std::vector<std::vector<Point2d> >::iterator compit =
components.begin(); compit != components.end(); compit++) {
int minx = output->width;
int miny = output->height;
int maxx = 0;
int maxy = 0;
for (std::vector<Point2d>::iterator it = compit->begin();
it != compit->end(); it++) {
miny = std::min(miny, it->y);
minx = std::min(minx, it->x);
maxy = std::max(maxy, it->y);
maxx = std::max(maxx, it->x);
}
CvPoint p0 = cvPoint(minx, miny);
CvPoint p1 = cvPoint(maxx, maxy);
std::pair<CvPoint, CvPoint> pair(p0, p1);
bb.push_back(pair);
}
return bb;
}
示例15: findBoundingBoxes
std::vector<std::pair<CvPoint,CvPoint> > findBoundingBoxes( std::vector<std::vector<Point2d> > & components,
std::vector<Chain> & chains,
std::vector<std::pair<Point2d,Point2d> > & compBB,
IplImage * output) {
std::vector<std::pair<CvPoint,CvPoint> > bb;
bb.reserve(chains.size());
for (std::vector<Chain>::iterator chainit = chains.begin(); chainit != chains.end(); chainit++) {
int minx = output->width;
int miny = output->height;
int maxx = 0;
int maxy = 0;
for (std::vector<int>::const_iterator cit = chainit->components.begin(); cit != chainit->components.end(); cit++) {
miny = std::min(miny,compBB[*cit].first.y);
minx = std::min(minx,compBB[*cit].first.x);
maxy = std::max(maxy,compBB[*cit].second.y);
maxx = std::max(maxx,compBB[*cit].second.x);
}
CvPoint p0 = cvPoint(minx,miny);
CvPoint p1 = cvPoint(maxx,maxy);
std::pair<CvPoint,CvPoint> pair(p0,p1);
bb.push_back(pair);
}
return bb;
}