We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Tag: Element

Remove all occurences of an element from vector in O(n) complexity

Suppose we have a vector of integers and we want to delete all occurences of a number from it i.e. Let’s say vector contain following numbers 1,2,5,4,5,1,5,7,8,9. Now we want to delete all the occurences of 5 from it, so that vector contents should become – 1 2 4 1 7 8 9 . Also …

Remove all occurences of an element from vector in O(n) complexityRead More

How to Erase / Remove an element from an unordered_map

In this article we will discuss the different ways to remove an element from an unordered_map. Unordered_map provides different overloaded version of erase() member function to delete key value pairs from map. Advertisements Erasing an element from an unordered_map by key Unordered_map provides following overloaded version of erase() that accepts a key by value and …

How to Erase / Remove an element from an unordered_mapRead More

C++ map : Erase element by key or Iterator or Range

In this article we will discuss the different ways to delete a key-value pair from map. std::map provides 3 overloaded version of erase() to remove elements from map i.e. Advertisements Erase by key Erase by Iterator Erase a range Lets discuss them one by one, Erase Element from Map by Key std::map provides a erase function that accepts …

C++ map : Erase element by key or Iterator or RangeRead 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++ : How to get element by index in List

In this article we will discuss how to get element by index in std::list. std::list doesn’t have operator [] std::list does not have random access operator [] because std::list internally store elements in doubly linked list. So, to access an element at nth location we need to iterate one by one from beginning to nth element. …

C++ : How to get element by index in ListRead More

C++ List – Find | Contains : How to search an element in std::list ?

In this article we will discuss different ways to find or search a given element in the list. std::list does not provide ant find() or contains() method. So, if we want to search for an element in list or check if an element exists in std::list, then we not to write some code for it i.e. …

C++ List – Find | Contains : How to search an element in std::list ?Read More

Cart

Your Cart is Empty

Back To Shop