Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
The C++ Programmer's Mindset

You're reading from   The C++ Programmer's Mindset Learn computational, algorithmic, and systems thinking to become a better C++ programmer

Arrow left icon
Product type Paperback
Published in Nov 2025
Publisher Packt
ISBN-13 9781835888421
Length 398 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Sam Morley Sam Morley
Author Profile Icon Sam Morley
Sam Morley
Arrow right icon
View More author details
Toc

Table of Contents (19) Chapters Close

Preface 1. Thinking Computationally 2. Abstraction in Detail FREE CHAPTER 3. Algorithmic Thinking and Complexity 4. Understanding the Machine 5. Data Structures 6. Reusing Your Code and Modularity 7. Outlining the Challenge 8. Building a Simple Command-Line Interface 9. Reading Data from Different Formats 10. Finding Information in Text 11. Clustering Data 12. Reflecting on What We Have Built 13. The Problems of Scale 14. Dealing with GPUs and Specialized Hardware 15. Profiling Your Code 16. Unlock Your Exclusive Benefits 17. Other Books You May Enjoy 18. Index

Maps and sets

A set is a container in which all the contained objects must compare not equal. Thus, adding a new object that is a duplicate of (or is equal to) an element that already exists in the set does not insert a new element. This is useful if one needs to keep track of all of the elements seen thus far. Determining whether an element is contained in a set should be a fairly fast operation (logarithmic in the size of the container for std::map), depending on the backing storage layout, as should adding new members. The standard library set stores the elements in order and uses a binary search to find elements. Maps and sets are often implemented as binary trees, such as a red-black tree, the structure of which is illustrated in Figure 5.2.

Figure 5.2: A simple tree with three nodes, one root node with two child nodes. Each node contains pointers to the left and right child nodes and a pointer to the parent node. Any of these can be null if there is no further node. Each node contains data, which may include a marker such as a red/black color in the case of red-black trees

Figure 5.2: A simple tree with three nodes, one root node with two child nodes. Each node contains pointers to the left and right child nodes and a pointer to the parent node. Any of these can be null if there is no further node...

lock icon The rest of the chapter is locked
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
The C++ Programmer's Mindset
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 ₹800/month. Cancel anytime
Modal Close icon
Modal Close icon