Questions tagged [std-pair]

A std::pair is an ordered, heterogeneous sequence of exactly two objects (it is a special case of std::tuple).

std::pair is a part of the C++ Standard Library, defined in the header <utility>.

Reference: https://en.cppreference.com/w/cpp/utility/pair

776 questions
-4
votes
2 answers

Initialize map with pair of std::arrays c++11

I would like to compile this lines. Insert to map pair of std::arrays. #include #include #include #include using namespace std; int main() { array l; array r; map
andrew
  • 3,083
  • 4
  • 24
  • 29
-4
votes
3 answers

C++ memory addresses of pair cout

When I use the following code I get a mem address(?) before the second item of the pair like this: 666, 0x6090e8667 666, 0x6090e8667 666, 0x6090e8667. What am I doing wrong? std::vector > > >…
Charis Ch
  • 1
  • 1
-4
votes
2 answers

Code doesn't compile using std::pair and constructors

The following code doesn't compile: #include #include #include using namespace std; template class meta { pair xy_pair; public: /* meta(const T1 & t1, const T2 & t2) : …
-4
votes
1 answer

How do I sort a list of pairs of ints?

I'm trying to enter data as a list of integer pairs, sort pairs by the first pair value, then the second value, and then output the sorted pair values; #include #include #include //experiment with list sort of…
-4
votes
3 answers

How to implement Pair class in Java like in C++

How to realize class pair in Java like in C++, for using like in C++?
Aisultan
  • 322
  • 2
  • 13
-5
votes
2 answers

Sort Vector of Pair of Points based on distance from origin

So the question statement is: Given an int n, follows by n pairs of numbers which are the coordinates of points. You must print out the point in the ordered entered, then print them in the order sorted by the distance from the origin. You will…
-5
votes
2 answers

Sorting on pairs in c++

I am writing a code for activity schedule problem. If i store the starting time and finishing time in an array of pairs like pairp[10] and after this i need to sort the activities as per finishing time with increasing finishing…
-6
votes
1 answer

Insert into map with pair as key and list as value

I have the following map in C++: typedef std::pair iPair; std::map< iPair, std::list< iPair > > world; I want to make insert and update of the map for a pair(u,v) -> push back in list: iPair src = make_pair(p1, u1); iPair dst =…
georgiana_e
  • 1,809
  • 10
  • 35
  • 54
-6
votes
2 answers

How to sort elements of pairs inside vector?

i have a pair of int and string inside a vector, how to sort them first on basis of int and if int value is duplicate then sort according to lexicographical manner of string. vector< pair > v;
Ni3_k
  • 56
  • 12
-9
votes
1 answer

< and > operators on pair

How does the < and > operators work on pair when first value of pair is equal? I have read 2 different concepts on this which has confused me. eg. pair p1(5,10); pair p2(5,12); What should be the answer of p1 > p2 ?
Vanshika
  • 49
  • 1
  • 6
-10
votes
3 answers

std::vector inserting std::pair

I am having trouble trying to insert a std::pair in the std::vector, with this code: template class AVectorContainner { public: AVectorContainner() { mVector= new std::vector; } typedef std::pair
Ricardo_arg
  • 520
  • 11
  • 28
1 2 3
51
52