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
Data Structures and Algorithms with the C++ STL

You're reading from   Data Structures and Algorithms with the C++ STL A guide for modern C++ practitioners

Arrow left icon
Product type Paperback
Published in Feb 2024
Publisher Packt
ISBN-13 9781835468555
Length 458 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
John Farrier John Farrier
Author Profile Icon John Farrier
John Farrier
Arrow right icon
View More author details
Toc

Table of Contents (30) Chapters Close

Preface 1. Part 1: Mastering std::vector FREE CHAPTER
2. Chapter 1: The Basics of std::vector 3. Chapter 2: Mastering Iterators with std::vector 4. Chapter 3: Mastering Memory and Allocators with std::vector 5. Chapter 4: Mastering Algorithms with std::vector 6. Chapter 5: Making a Case for std::vector 7. Part 2: Understanding STL Data Structures
8. Chapter 6: Advanced Sequence Container Usage 9. Chapter 7: Advanced Ordered Associative Container Usage 10. Chapter 8: Advanced Unordered Associative Container Usage 11. Chapter 9: Advanced Container Adaptor Usage 12. Chapter 10: Advanced Container View Usage 13. Part 3: Mastering STL Algorithms
14. Chapter 11: Fundamental Algorithms and Searching 15. Chapter 12: Manipulation and Transformation 16. Chapter 13: Numeric and Range -Based Operations 17. Chapter 14: Permutations, Partitions, and Heaps 18. Chapter 15: STL with Ranges 19. Part 4: Creating STL-Compatible Types and Algorithms
20. Chapter 16: Creating STL-Types Containers 21. Chapter 17: Creating STL -Compatible Algorithms 22. Chapter 18: Type Traits and Policies 23. Part 5: STL Data Structures and Algorithms: Under the Hood
24. Chapter 19: Exception Safety 25. Chapter 20: Thread Safety and Concurrency with the STL 26. Chapter 21: STL Interaction with Concepts and Coroutines 27. Chapter 22: Parallel Algorithms with the STL 28. Index 29. Other Books You May Enjoy

std::map

A sibling to the std::set container, std::map is about relationships. It connects unique keys to specific values, forming a pair. In layman’s terms, imagine a dictionary where each word (key) has a unique definition (value).

Purpose and suitability

std::map is an ordered associative container that stores key-value pairs, ensuring unique keys. Its underlying data structure is typically a balanced binary tree (such as a red-black tree (RBT)). The main advantages include the following:

  • Logarithmic access, insertion, and deletion times
  • Maintaining key-value pairs in sorted order by keys

Use std::map in the following scenarios:

  • When you need to associate values with unique keys
  • When maintaining the order of keys is important
  • When frequent access, insertion, or deletion operations are required, and they need to be efficient

Ideal use cases

The following are some ideal use cases of std::map:

  • Dictionary or phonebook...
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 ₹800/month. Cancel anytime