/Data-Structures-and-Algorithms-with-the-CPP-STL

Data Structures and Algorithms with the C++ STL, Published by Packt

Primary LanguageC++MIT LicenseMIT

Data Structures and Algorithms with the C++ STL

This is the code repository for Data Structures and Algorithms with the C++ STL, published by Packt.

A guide for modern C++ practitioners

What is this book about?

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.

This book covers the following exciting features:

  • 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

If you feel this book is for you, get your copy today!

https://www.packtpub.com/

Instructions and Navigations

All of the code is organized into folders.

The code will look like the following:

template <typename T,
 typename AllocatorPolicy = std::allocator<T>>
class CustomVector {
 // Implementation using AllocatorPolicy for memory
 // allocation
};

Following is what you need for this book: 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.

With the following software and hardware list you can run all code files present in the book (Chapter 1-22).

Software and Hardware List

Chapter Software required OS required
1-22 C++ Windows, Mac OS X, and Linux (Any)
1-22 C++ STL Windows, Mac OS X, and Linux (Any)

Errata

  • Page 14 (code block 2):

     #include <iostream>
     #include <vector>
     int main() {
       std::vector<int> numbers = {10, 20, 30, 40, 50};
       try {
         const auto secondElement = numbers.at(1);
         std::cout << "The second element is: " << secondElement
         << "\n";
       } catch (const std::out_of_range &e) {
       std::cerr << "Error: " << e.what() << "\n";
      }
       try {
         const auto outOfBoundsElement = numbers.at(10);
         std::cout << "Accessing an out-of-bounds index: "
           << outOfBoundsElement << "\n";
           } catch (const std::out_of_range &e) {
           std::cerr << "Error: " << e.what() << "\n";
          }
       return 0;
      }
    

    should be

    #include
    #include
    int main()
    {
      std::vector numbers = { 10, 20, 30, 40, 50 };
      try {
      const auto secondElement = numbers.at(1);
      std::cout << "The second element is: " << secondElement << "\n";
    }
    catch (const std::out_of_range& e) {
      std::cerr << "Error: " << e.what() << "\n";
    }
    
    try {
      // This will throw an exception because there are only 5 elements.
      const auto outOfBoundsElement = numbers.at(10);
     }
    catch (const std::out_of_range& e) {
      std::cerr << "Error: " << e.what() << "\n";
    }
    
    return 0;
    }
    

Related products

Get to Know the Author

John Farrier, a renowned company founder and software engineer, excels in managing high-stakes software projects for defense and commercial clients. As the Co-Founder and CEO of Hellebore Consulting Group, he drove substantial growth and revolutionized mission systems architectures. His technical expertise includes C++, Design Patterns, DevOps, Signal Processing, and Game Engine Design. John is a featured speaker on Organizational Leadership, Agile Project Management, C++, and Simulation. Currently, Founder and CEO of Polyrhythm Software, John continues to work to deliver exceptional software to defense and commercial sectors, advocating a robust engineering culture prioritizing collective growth and innovation.