Welcome to the eighth and final part of our C++ Standard Template Library series. In this eighth part, we will be discussing in brief about Modifying Algorithms. This series comes to an end even though some quick and dirty research will show the STL is rather large.
The reason we are stopping here is to change focus to talking about other libraries like Boost and Qt. More importantly, we will be starting our C++ tutorial series on modern C++ which will include videos on our Partner YouTube Channel.
As usual, if you are catching up with us now I would like to direct you to the start of this series. If you have some knowledge in STL then you can fast track to ore recent articles in this series. So without much ado, we will pick up from where we left off on talking about Non-Modifying algorithms.
What are Modifying Algorithms?
In simplest terms, Modifying Algorithms can be described as those algorithms that alter the data on which they are applied to operate on. For example, if I apply an algorithm to change the order of elements in an array and return the array with the new order, that algorithm can be termed as a modifying algorithm.
Again we will show you some of the common algorithms to illustrate how these algorithms are used. If you missed our article on Algorithms and Iterators you can go back to part six of this STL series and read that article to brush up further on algorithms.
Let’s start off by looking at some of the many copy algorithms. These basically modify the contents of the one variable based on the value of a different variable. Look at these examples:
Now let’s take a look at moving some data around. Take a look at these examples:
Here are a few last examples:
There you have it. By now you should have a general idea about algorithms that do not modify data vs the modifying algorithms.