C++ Standard Library: Sequential Containers

This course will teach you in a practical way, with slides and demo code, how to use some important containers available in the C++ Standard Library (e.g. std::vector). You’ll learn their pros and cons, common operations, and how to fix subtle bugs.
Course info
Level
Intermediate
Updated
Oct 1, 2019
Duration
2h 25m
Table of contents
Course Overview
Storing Sequences of Elements with the Standard std::vector Container
Breaking the Ice with Useful Standard Algorithms: Sorting std::vector
Inserting, Removing, and Searching Elements
Safely Encapsulating Fixed-size Arrays with std::array
Managing Linked-lists with std::list
Description
Course info
Level
Intermediate
Updated
Oct 1, 2019
Duration
2h 25m
Description

Non-trivial computer programs need to store data and process it. Developing data structures and containers from scratch in C++ is a daunting and bug-prone task. In fact, you would have to consider advanced aspects like manual memory and resource management, proper handling subtle corner cases, writing both generic code and code that is optimized for special cases, and soon. Thankfully, the C++ Standard Library already offers containers that are high-quality, efficient, and well-tested. It’s a joy to develop C++ code reusing them; in fact, using these containers in your C++ code will boost your productivity, as the C++ Standard Library gives youon a platter high-quality implementations of common and useful data structures which you can easily leverage in your C++ code. C++ Standard Library’s maintainers spend hours looking at these data structures and improving, refining, and optimizing their C++ implementation code. In this course, C++ Standard Library: Sequential Containers, you will gain an understanding of howto simply reuse that treasure in your own C++ applications. First, you will learn about std::vector, which is a flexible dynamic array that should be the default container of choice in many contexts in C++ applications. You will enjoy the automatic resource management (for bothmemory resources and non-memory ones) offered by std::vector, which will help you develop both efficient and safer C++ code. This portion will also show you how convenient it is, for example, to grow a vector, while still keeping the contiguous memory layout requirement for its elements. Next, you will discover important operations, like inserting, removing and searching elements using both C++ container methods and Standard Library’s algorithms. In fact, C++ standard containers and algorithms are kind of like “bread and butter,” and you can do great things using both. You don’t need to have any previous experience with the C++ Standard Library, as I’ll teach you its great and flexible design based on containers, algorithms, and iterators, and you’ll see how containers are wired with algorithms using iterators, and how you can reuse the same algorithms with different containers. Next, you will explore some specific cases when you can use a zero-overhead standard container that wraps fixed-size C-style arrays in a convenient high-level safe C++ interface: it’s std::array. I’ll compare and contrast it against std::vector, and you’ll learn pros and cons of each. This section will also cover how to use the std::list container, if you need a high-level C++ abstraction based on the doubly-linked list data structure. Moreover, seeing the same algorithms used with different containers will also work very well as a reinforcement learning experience for you. I’ll also show you some subtle bugs, that are especially frequent for those who are just starting to learn the C++ Standard Library’s containers, and how to fix them. I hope this will save you time and headache during your C++ programming. To proficiently follow this course, you only need a basic knowledge of C++ language features. After completing this course, you will be able to use high-quality efficient andwell-tested C++ Standard Library containers like std::vector, std::array, and std::list in your own C++ code. You will have practical knowledge about them and will be able to make proper judgement about picking one or the other based on the problem at hand. You will also gain a foundational knowledge about important common operations with these standard containers, likeinserting, removing and searching items. C++ Standard Library’s maintainers spend hours looking at these data structures, and improving, refining, and optimizing their C++ implementation code. In this course, C++ Standard Library: Sequential Containers, you will gain an understanding of how to simply reuse that treasure in your own C++ applications. First, you will learn about std::vector, which is a flexible dynamic array, that should be the default container of choice in many contexts in C++ applications. You will enjoy the automatic resource management (for both memory resources and non-memory ones) offered by std::vector, which will help you develop both efficient and safer C++ code. This portion will also show you how convenient is for example to grow a vector, still keeping the contiguous memory layout requirement for its elements. Next, you will discover important operations, like inserting, removing and searching elements, using both C++ container methods and Standard Library’s algorithms. In fact, C++ standard containers and algorithms are kind of like “bread and butter”, and you can do great things using both. You don’t need to have any previous experience with the C++ Standard Library, as I’ll teach you its great and flexible design based on containers, algorithms and iterators, and you’ll see how containers are wired with algorithms using iterators, and how you can reuse the same algorithms with different containers. Next, you will explore some specific cases you can use a zero-overhead standard container that wraps fixed-size C-style arrays in a convenient high-level safe C++ interface: it’s std::array. I’ll compare and contrast it against std::vector, and you’ll learn pros and cons of each one. This section will also cover how to use the std::list container, if you need a high-level C++ abstraction based on the doubly-linked list data structure. Moreover, seeing the same algorithms used with different containers will also work very well as a reinforcement learning experience for you. I’ll also show you some subtle bugs, that are especially frequent in those starting learning the C++ Standard Library’s containers, and how to fix them. I hope this will save you time and headache during your C++ programming. To proficiently follow this course, you only need a basic knowledge of C++ language features. After completing this course, you will be able to use high-quality efficient and well-tested C++ Standard Library containers like std::vector, std::array and std::list in your own C++ code. You will have practical knowledge about them, and will be able to make proper judgement about picking one or the other based on the problem at hand. You will also gain a foundational knowledge about important common operations with these standard containers, like inserting, removing and searching items.

About the author
About the author

Giovanni Dicanio is a computer programmer specialized in both cross-platform C and C++, and Windows operating system development. He is a Microsoft MVP for Visual C++. He also blogs on msmvps.com/gdicanio.

More from the author
Practical C++14 and C++17 Features
Intermediate
2h 33m
Dec 11, 2017
More courses by Giovanni Dicanio
Section Introduction Transcripts
Section Introduction Transcripts

Course Overview
(Music) Hi everyone. My name is Giovanni Dicanio, and welcome to my course on C++ Standard Library: Sequential Containers. I'm a programmer specialized in C and C++ and a Pluralsight author. Do you know that the C++ standard library offers high-quality, efficient, and well-tested implementations of useful data structures like flexible dynamic arrays? Are you interested in learning about some of these standard containers with an engaging combination of slides and demo code? Well, this course is for you. In this course, we are going to cover some useful containers implemented in the C++ Standard Library, including how to perform common operations with them. Some of the major topics that we will cover include using std::vector, which is a great option when you need a flexible dynamic array, breaking the ice with the Standard Library's algorithm for searching and sorting elements, safely encapsulating fixed-size arrays with std::array, managing linked lists with std::list, analyzing subtle bugs and how to fix them. By the end of this course, you'll have a practical knowledge of some useful C++ Standard Library's containers like std::vector, std::array, and std::list, including how to perform common operations with them. Before beginning the course, you should be familiar with the basic features of the C++ language. I hope you'll join me on this journey to learn about practical usage of some useful C++ standard containers with the C++ Standard Library: Sequential Containers course, at Pluralsight.