Skip to main content

Posts

Showing posts with the label stl containers

C++ STL (Containers) Tutorial For Beginners Learn STL Hacks Part -2

In continuation of my STL tutorial series, I'll be introducing to some more STL containers in this post. The containers I shall be covering include: CONTAINERS String Streams Map Multiset Priority Queue String Streams Stringstream is the processing of input/output strings. The stringstream class in C++ allows a string object to be treated as a stream. It is used to operate on strings. By treating the strings as streams we can perform extraction and insertion operation from/to string just like cin and cout streams. C++ provides two interesting objects for it: ‘istringstream’ (input stringstream ) and ‘ostringstream’ (output stringstream). Both of these are declared in #include< stream >. Object istringstream allows you to read from a string like you do from standard input. The ostringstream object is used to do formatting output. Insertion And Extraction Operations Using stringstream Insertion (i) Using Insertion Operator (<<) Data i...

C++ STL (Containers) Tutorial For Beginners Learn STL Hacks Part -1

So, As I said that I will be writing in the next post about STL hacks and tricks so here I am with this post. /* Important Note : STL: Standard Library  ( To Import It Use: #include<bits/stdc++.h> ) Container types (and algorithms, functors, and all STL as well) are defined not in the global namespace, but in a special namespace called “std.”  Add the following line after your includes and before the code begin: using namespace std; otherwise use:  std::'container' */ You must have g++ compiler installed on your PC for using it. STL is mostly used by intermediate users of C++ and it is quite helpful in Competitive Coding, it saves a lot of time and all the algorithms are implemented with the best possible Time and Space Complexities available. STL is quite vast and we'll be step by step covering all of it, this post is a brief intro of : Containers   Vector  Pairs  Iterators      Set CONTAINERS In n...