Jonathan Boccara's blog

STL Algorithms on Sets

Published December 29, 2017 - 1 Comment

If you want to become proficient at manipulating collections in C++, you have to know your STL algorithms. And in particular, you have to know your STL algorithms on sets.

The algorithms on sets are less famous than the classical std::for_each or std::accumulate algorithms but they are just as useful, if not more. The algorithms on sets include for example std::set_difference (which is my favourite STL algorithm).

In this week’s video, you’ll see the algorithms on sets that the STL offers, what we mean by a set in the first place, and an example of their usage in code.

Indeed, I’m getting more used to the filming equipment to make videos so, as many of you suggested, the videos on Fluent C++ now contain some live coding examples!

Here, we see a practical case: a collection of sorted values has been modified, and we have two versions of it: the collection as it was before and the collection as it is now, after the modification. How do we find out which values have been added? Which have been removed?

With the set algorithms, it’s a walk in the park. Have a look by yourself:

Related articles:

Share this post! Facebooktwittergoogle_pluslinkedin    Don't want to miss out ? Follow:   twitterlinkedinrss