Category : std-pair

how can i pick the different numbers of both numbers in a pair entry more efficiently if(loc[0].first!=loc[1].first && loc[0].first!=loc[2].first) x=loc[0].first; if(loc[1].first!=loc[0].first && loc[1].first!=loc[2].first) x=loc[1].first; if(loc[2].first!=loc[0].first && loc[2].first!=loc[1].first) x=loc[2].first; if(loc[0].second!=loc[1].second && loc[0].second!=loc[2].second) y=loc[0].second; if(loc[1].second!=loc[0].second && loc[1].second!=loc[2].second) y=loc[1].second; if(loc[2].second!=loc[0].second && loc[2].second!=loc[1].second) y=loc[2].second; Source: Windows Que..

Read more

I want to order some strings by their indexes. And I don’t want to use two different types of priority queue. #include <string> #include <queue> #include <utility> int main() { const std::string &a = "hello"; std::pair<int, const std::string &> p = std::make_pair(1, a); std::priority_queue<std::pair<int, const std::string &>> pq; pq.push(p); return 0; } So how to ..

Read more