Book description
Explore the C++ 23 STL with practical guidance on vectors, algorithms, and custom types for intermediate developers, enriched by real-world examples.
Key Features
- Master the std::vector and understand why it should be your default container of choice
- Understand each STL algorithm and its practical applications
- Gain insights into advanced topics such as exception guarantees and thread safety
- Purchase of the print or Kindle book includes a free PDF eBook
Book Description
While the Standard Template Library (STL) offers a rich set of tools for data structures and algorithms, navigating its intricacies can be daunting for intermediate C++ developers without expert guidance. This book offers a thorough exploration of the STL’s components, covering fundamental data structures, advanced algorithms, and concurrency features.
Starting with an in-depth analysis of the std::vector, this book highlights its pivotal role in the STL, progressing toward building your proficiency in utilizing vectors, managing memory, and leveraging iterators. The book then advances to STL’s data structures, including sequence containers, associative containers, and unordered containers, simplifying the concepts of container adaptors and views to enhance your knowledge of modern STL programming. Shifting the focus to STL algorithms, you’ll get to grips with sorting, searching, and transformations and develop the skills to implement and modify algorithms with best practices. Advanced sections cover extending the STL with custom types and algorithms, as well as concurrency features, exception safety, and parallel algorithms.
By the end of this book, you’ll have transformed into a proficient STL practitioner ready to tackle real-world challenges and build efficient and scalable C++ applications.
What you will learn
- Streamline data handling using the std::vector
- Master advanced usage of STL iterators
- Optimize memory in STL containers
- Implement custom STL allocators
- Apply sorting and searching with STL algorithms
- Craft STL-compatible custom types
- Manage concurrency and ensure thread safety in STL
- Harness the power of parallel algorithms in STL
Who this book is for
This book is for intermediate-level C++ developers looking to enhance their software development skills. Familiarity with basic C++ syntax and object-oriented programming (OOP) as well as some exposure to data structures and algorithms is assumed. Tailored to software engineers, computer science students, and hobbyist programmers, this book delves into C++ STL for practical application, performance enhancement, and efficient coding practices.
Table of contents
- Data Structures and Algorithms with the C++ STL
- Contributors
- About the author
- About the reviewer
- Preface
- Part 1: Mastering std::vector
- Chapter 1: The Basics of std::vector
- Chapter 2: Mastering Iterators with std::vector
- Chapter 3: Mastering Memory and Allocators with std::vector
- Chapter 4: Mastering Algorithms with std::vector
- Chapter 5: Making a Case for std::vector
- Part 2: Understanding STL Data Structures
- Chapter 6: Advanced Sequence Container Usage
- Chapter 7: Advanced Ordered Associative Container Usage
- Chapter 8: Advanced Unordered Associative Container Usage
- Chapter 9: Advanced Container Adaptor Usage
- Chapter 10: Advanced Container View Usage
- Part 3: Mastering STL Algorithms
- Chapter 11: Fundamental Algorithms and Searching
- Chapter 12: Manipulation and Transformation
- Chapter 13: Numeric and Range -Based Operations
- Chapter 14: Permutations, Partitions, and Heaps
- Chapter 15: STL with Ranges
- Part 4: Creating STL-Compatible Types and Algorithms
-
Chapter 16: Creating STL-Types Containers
- Technical requirements
- The advantages of STL-compatible types
- Interacting with STL algorithms
- Essential requirements for compatibility
- Crafting iterators for custom types
-
Effective operator overloading
- Operator overloading in C++
- Considerations in overloading
- Implementing arithmetic operators for custom types
- Overloading relational operators for clear comparisons
- Simplifying tasks with assignment and compound assignment
- Stream operators for efficient I/O
- Operator precedence and associativity in overloading
- The role of operator overloading in C++
- Creating custom hash functions
- Summary
- Chapter 17: Creating STL -Compatible Algorithms
- Chapter 18: Type Traits and Policies
- Part 5: STL Data Structures and Algorithms: Under the Hood
- Chapter 19: Exception Safety
-
Chapter 20: Thread Safety and Concurrency with the STL
- Technical requirements
- Concurrency versus thread safety
- Understanding thread safety
- Race conditions
- Mutexes and locks
- STL containers and thread safety
- Specific container concerns
- Concurrency support within the STL
- Using std::thread, std::async, std::future, and thread -local storage
- Concurrent data structures in the STL
- Summary
- Chapter 21: STL Interaction with Concepts and Coroutines
-
Chapter 22: Parallel Algorithms with the STL
- Technical requirements
-
Introduction to execution policies
- The <execution> header– enabling parallelism in STL algorithms
- Implementing parallel execution
- Reflecting on the transition to parallel STL
- Incorporating execution policies
- Integrating policies with standard algorithms
- Understanding parallel execution policies
- Selecting the appropriate execution policy
- The impact of constexpr on algorithms and containers
- Performance considerations
- Summary
- Index
- Other Books You May Enjoy
Product information
- Title: Data Structures and Algorithms with the C++ STL
- Author(s):
- Release date: February 2024
- Publisher(s): Packt Publishing
- ISBN: 9781835468555
You might also like
book
C++ Data Structures and Algorithm Design Principles
Get started with C++ programming by learning how to build applications using its data structures and …
book
Mastering the C++17 STL
This book breaks down the C++ STL, teaching you how to extract its gems and apply …
book
Optimized C++
In today’s fast and competitive world, a program’s performance is just as important to customers as …
book
Functional Programming in C++
Functional Programming in C++ teaches developers the practical side of functional programming and the tools that …