We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Tag: set

C++ Set example and Tutorial – Part 1

In this article we will discuss how to use std::set with default sorting criteria. std::set – Introduction std::set is an associative container and header that need to be include for it is,#include<set> Advertisements Benefits and Features of std::set: It’s doesn’t allow duplicate elements i.e. it only contains unique elements. Std::set can contain element of any …

C++ Set example and Tutorial – Part 1Read More

Set vs Map : How to choose a right associative container ?

In this article we will discuss how set and map are different and what factors we need to keep in mind while choosing right associative container. Let’s start from set, Set : Advertisements Set is an associative container which we need to store unique elements. It always keeps the elements in sorted order. Internally it …

Set vs Map : How to choose a right associative container ?Read More

How to Access Element by index in a Set | C++

In this article we will discuss how to access an element by index in a Set. std::set is an associative container, which internally store elements in a balanced binary search tree and it doesn’t provide random access operator []. Advertisements Therefore accessing a random element from set by index is little tricky. Accessing nth element in …

How to Access Element by index in a Set | C++Read More

C++ : Different ways to insert elements in Set

In this article we will discuss different ways to insert an element in Set. Set provides 3 different overloaded version of insert() function to add element in set. Let’s discuss them one by one, Advertisements Inserting a Single element in Set and checking the result Set is an associative container and contains only unique elements, …

C++ : Different ways to insert elements in SetRead More

Different ways to iterate over a set in C++

In this article we will discuss different ways to iterate over a set in C++. Let’s create a set of strings i.e. Advertisements // Set of strings std::set<std::string> setOfStr = { “jjj”, “khj”, “bca”, “aaa”, “ddd” }; Now let’s iterate over it and print the contents on screen using different methods i.e. Iterating over a …

Different ways to iterate over a set in C++Read More

Different ways to Erase / Delete an element from a Set in C++

In this article we will discuss different ways to remove an element from Set. std::set provides 3 overloaded version of erase() member function. We will discuss them one by one. Advertisements Suppose we have a set of strings i.e. //Set Of Strings std::set<std::string> setOfStrs = {“Hi”, “Hello”, “is”, “the”, “at”, “Hi”, “is”, “from”, “that”}; Let’s …

Different ways to Erase / Delete an element from a Set in C++Read More

Erase elements from a Set while Iterating in C++ & Generic erase_if()

In this article we will discuss how to erase elements from a set while iterating over it. Erasing elements from std::set while Iterating std::set provides a member function erase() that accepts an iterator as an argument and deletes it from the set i.e. iterator erase (const_iterator position); But it makes the passed iterator invalid. From …

Erase elements from a Set while Iterating in C++ & Generic erase_if()Read More

C++ : How to check if a Set contains an element | set::find vs set::count?

In this article we will discuss how to check if a given element exists in set or not. Suppose we have a set of strings i.e. Advertisements // Set of strings std::set<std::string> setOfStrs = { “the”, “is”, “of” , “from” , “at” , “hello” , “the” }; Now we wnat to check if any given …

C++ : How to check if a Set contains an element | set::find vs set::count?Read More

Python Set: add() vs update()

In this article we will discuss the main differences between add() and update() functions of Set in python. In python, set class provides two different functions to add or append elements in the set. Before going into the differences, first let’s have a basic overview about them, Advertisements set.add() Function: set.add(element) It accepts an element …

Python Set: add() vs update()Read More

Cart

Your Cart is Empty

Back To Shop