All about pair STL in c++ for competitive programming( initialization, traversal and methods/functions ) :
pair STL Important Points: It is a simple utility container which consists of a single pair. A pair contains values (t1 and t2) which may be of different types . It provides a way to store two heterogeneous objects as a single unit. Keyword ' first ' is used to refer to the first value (t1) and keyword ' second ' is used to refer to the second value (t2) . A pair can be copied and can be compared with other pairs also. Remember to use the header file #include<utility> before using pair STL. map and pair: map STL uses pair only to store (key, value) pairs in it. By default, first value (t1) is the key and the second value (t2) is the value associated with the key. Different ways to initialize a pair STL 1. declaring a pair and using make_pair( ) to make a pair : pair < int, string > p ; p = make_pair ( 10, "gamma" ) ; 2. using first and second keyw...
I can say one thing that "really you made coding simple as your name suggest" hats off!!
ReplyDeleteReally means a lot. Thank you sooo much❤️.
Delete