Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering the C++17 STL

You're reading from   Mastering the C++17 STL Make full use of the standard library components in C++17

Arrow left icon
Product type Paperback
Published in Sep 2017
Publisher Packt
ISBN-13 9781787126824
Length 384 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Arthur O'Dwyer Arthur O'Dwyer
Author Profile Icon Arthur O'Dwyer
Arthur O'Dwyer
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Classical Polymorphism and Generic Programming 2. Iterators and Ranges FREE CHAPTER 3. The Iterator-Pair Algorithms 4. The Container Zoo 5. Vocabulary Types 6. Smart Pointers 7. Concurrency 8. Allocators 9. Iostreams 10. Regular Expressions 11. Random Numbers 12. Filesystem

A particular set of skills: std::list<T>

The container std::list<T> represents a linked list in memory. Schematically, it looks like this:

Notice that each node in the list contains pointers to its "next" and "previous" nodes, so this is a doubly linked list. The benefit of a doubly linked list is that its iterators can move both forwards and backwards through the list--that is, std::list<T>::iterator is a bidirectional iterator (but it is not random-access; getting to the nth element of the list still requires O(n) time).

std::list supports many of the same operations as std::vector, except for those operations that require random access (such as operator[]). It can afford to add member functions for pushing and popping from the front of the list, since pushing and popping from a list doesn't require expensive move operations.

In general...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime