
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7197 Articles for C++

743 Views
To remove an item from a C++ STL vectors by value, you can use the std::remove inside the argument of erase method of the vector. There are some other methods as well. In this article, we will learn all the approaches to remove an item from a C++ STL vector. The easiest way to remove an item from a vector is to use the std::remove algorithm inside the erase method of the vector. For example: vector v = {1, 2, 2, 3, 2, 5}; // Remove all occurrences of 2 v.erase(remove(v.begin(), v.end(), 2), v.end()); Remove an ... Read More

1K+ Views
In C++ STL, both emplace and insert functions are used to add elements to containers such as vectors, lists, and maps. But, emplace is more efficient than insert as it avoids unnecessary copying of object and does the insertion more efficiently than insert operation. In this article, we will discuss the all the differences between emplace and insert with examples. Insert in C++ STL The insert function in C++ STL is used to add new elements to a container (ie, set, map, vector, list, etc.). Following is the syntax of insert function: // insert into a pair multiset set1; ... Read More

4K+ Views
Generally, the default behavior of map and multimap map is to store elements is in ascending order. But we can store element in descending order by using the greater function. Map in Descending Order We use a map to store elements in descending order with the help of the greater function. We perform various operations like inserting elements, finding an element, counting occurrences of keys, and removing elements from the map. Functions are used here - m::find() – Returns an iterator to the element with key value ‘b’ in the map if found, else returns the iterator to ... Read More

578 Views
Vector is a special type of array in C++, which have ability to resize itself automatically during insertion and deletion of elements.. In this article, we will learn how to use the vector container from the Standard Template Library (STL) in C++. What is a Vector? A vector is a container that stores data elements in a dynamic contiguous memory. It is similar to arrays but can change its size dynamically during execution. Meaning, we doesn't need explicitly mention the size of a vector, it will be calculated automatically by counting number of elements in it. Similar to arrays, ... Read More

1K+ Views
Stack is a linear data structure that follows the Last In First Out (LIFO) principle. In this article, we will learn how to use the stack container from the Standard Template Library (STL) in C++. What is Stack? A stack is a container that stores data in a way that the last inserted data will be the first to be removed. This is same as a stack of plates, where the last plate placed on the top is the first one to be removed. The STL library of C++ provides a pre-defined stack data structure which comes with all ... Read More

180 Views
In this C++ program, we implement Sorting containers in STL.Functions and descriptions:Functions used here: l.push_back() = It is used to push elements into a list from the front. l.sort() = Sorts the elements of the list. Where l is a list object.Example Code#include #include #include #include using namespace std; int main() { list l; list::iterator it; int c, i; while (1) { cout

746 Views
The Set Union is an operation used to find all elements that are present in either of the sets or in both. In this article, we will learn how to use the set_union algorithm from the Standard Template Library (STL) in C++ to find the union of two sets. What is Set Union? The set union is an arithmetic operation performed between two sets to find all elements that are present in either of the sets or in both. In C++, we have set_union which is a built-in algorithm provided by C++ STL that computes the union of two ... Read More

378 Views
The Set Symmetric Difference is an operation used to find all elements that are present in either of the sets but not in both. In this article, we will learn how to use the set_symmetric_difference algorithm from the Standard Template Library (STL) in C++ to find the symmetric difference of two sets. What is Set Symmetric Difference? The set symmetric difference is an arithmetic operation performed between two sets to find all elements that are present in either of the sets but not in both. In C++, we have set_symmetric_difference(), which is a built-in function provided by C++ STL ... Read More

728 Views
The Set Intersection is an operation used to find all elements that are common in both sets. In this article, we will learn how to use the set_intersection algorithm from the Standard Template Library (STL) in C++ to find the intersection of two sets. What is Set Intersection? The set intersection is an arithmetic operation performed between two sets to find all elements that are common in both sets. In C++, we have set_intersection which is a built-in algorithm provided by C++ STL that computes the intersection of two sorted ranges of sets. That is, it returns the elements ... Read More

929 Views
The Set Difference is an operation used to find all elements present in the first set but not in the second. In this article, we will learn how to use the set_difference algorithm from the Standard Template Library (STL) in C++ to find the difference of two sets. What is Set Difference? The set difference is an arithmetic operation performed between two sets to find all elements present in the first set but not in the second. In C++, we have set_difference which is a built-in algorithm provided by C++ STL that computes the set difference of two sorted ... Read More