Tag: From
How to erase elements from a list in c++ using iterators
In this article we will see how to erase elements from a std::list using iterators. std::list provides 2 member function to delete elements using iterators i.e. Advertisements iterator erase (const_iterator position); It deletes the element representing by passed iterator “position” and returns the iterator of element next to last deleted element. iterator erase (const_iterator first, const_iterator last); …
How to erase elements from a list in c++ using iteratorsRead More
How to call Base class’s overridden method from Derived class in java
In this article we will discuss how to call parent class’s overridden method from a derived class method in Java. Suppose we have a Base class which has a function display() i.e. Advertisements class Base { public void display() { System.out.println(“Base :: display”); } } Now we will create a Derived class that will extend this …
How to call Base class’s overridden method from Derived class in javaRead 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
How to Add / Subtract Days, Months or Years from a Date in C++
In this article we will discuss how to add or subtract days, months & Years from a date object. Add / Subtract Days from a Date For example, if current date is 21 March 2016. Then subtracting 100 days from this date will make the date 12 Dec 2015 Advertisements For this we will use …
How to Add / Subtract Days, Months or Years from a Date in C++Read More
Java : How to Remove elements from HashMap while Iterating
In this article we will discuss different ways to remove elements from HashMap while Iterating. Let’s create a HashMap of String as Key and Integer as value and add some elements into it i.e. Advertisements // Create a HashMap of string and int HashMap<String, Integer> wordFreqMap = new HashMap<>(); // Add elements in Map wordFreqMap.put(“this”, …
Java : How to Remove elements from HashMap while IteratingRead 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
How to read data from a csv file in C++ ?
In this article we will discuss and create a class to read data from a CSV File. What is a CSV File ? A csv file is a kind of flat file used to store the data. In this each row contains data separated by comma. For example, Advertisements 20,hi,99 3,4,5 a,b,c 3,4,1 Creating a …
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
How to copy all Values from a Map to a Vector in C++
In this article we will discuss how to fetch all values from a map and put them in vector. Suppose we have a map of words and their frequency count i.e. Advertisements // Map of string & int // To store the frequency count of words std::map<std::string, int> wordMap = { { “is”, 6 }, …
How to copy all Values from a Map to a Vector in C++Read More
How to remove Substrings from a String in C++
In this article we will discuss how to remove single or multiple sub strings from a given string. std::string class provides a member function string::erase() to remove some characters from a given position i.e. Advertisements string& erase (size_t pos = 0, size_t len = npos); It accepts a position and length of characters to be …