32,39 €
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.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 563
Veröffentlichungsjahr: 2024
Data Structures and Algorithms with the C++ STL
A guide for modern C++ practitioners
John Farrier
Copyright © 2024 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Group Product Manager: Kunal Sawant
Publishing Product Manager: Samriddhi Murarka
Book Project Manager: Manisha Singh
Senior Editor: Aditi Chatterjee
Technical Editor: Jubit Pincy
Copy Editor: Safis Editing
Indexer: Hemanigini Bari
Production Designer: Gokul Raj S.T
DevRel Marketing Coordinator:Shrinidhi Manoharan
First published: February 2024
Production reference: 1160224
Published by
Packt Publishing Ltd.
Grosvenor House
11 St Paul’s Square
Birmingham
B3 1RB, UK.
ISBN 978-1-83546-855-5
www.packtpub.com
To my parents, John and Sharon, who ignited the spark of curiosity within me by introducing me to the world of computers and not being too upset when I broke them—thank you for setting me on this path. To my wife, Lisa, whose unwavering support has been my cornerstone throughout this journey. And to my children, Corbin and Regan, who give every day a purpose and every challenge a reward—this book is for you. Your love and belief in me make every endeavor worthwhile.
John Farrier has over 25 years of experience as a successful founder and software engineering leader, particularly noted for delivering high-value projects to the U.S. Air Force clients.
Under his leadership as Co-Founder and CEO, his first company, Hellebore, saw remarkable growth and was pivotal in the defense sector, particularly in designing advanced mission systems architectures for next-generation aircraft.
In his expansive technical repertoire, John commands expertise in Design Patterns, C++, Python, DevOps, AI, Game Engine Design, Large-Scale Agile Project Management, and Modeling & Simulation. Leveraging Agile principles and stream-aligned teams, he constantly explores the outer reaches of software engineering possibilities. John’s credentials are reinforced by numerous publications in the realm of Modeling and Simulation.
John’s commitment extends beyond mere technical excellence. He’s an unwavering advocate for fostering strong software cultures, emphasizing collaboration and career evolution. He operates with a strong ethos of principle-based decision-making and hyper-transparency, fostering both trust and clarity in professional relationships.
At present, John leads Polyrhythm Software, one of a new generation of software companies focused on delivering high-value software to the Department of Defense and commercial clients.
Kevin Carpenter, an experienced Software Engineer, excels in crafting high-availability C++ solutions for Linux and Windows, with expertise in transaction software, financial modeling, and system integration. As a Lead Project Engineer, he ensures secure, high-speed credit card transactions. In his prior position, he played a lead role in developing an interest rate risk model for large credit unions, enhancing legacy code, and optimizing ERP data integration.
Kevin actively engages in the C++ community, volunteering at conferences such as CppCon, C++ on Sea, and C++Now, where he holds key positions of Speaker Liaison and Volunteer Coordinator/Chair. His diverse contributions to the C++ community showcase his commitment to excellence and drive for collaborative growth, leaving a lasting impact on the tech world.
In this Part, we will build our knowledge of C++ Standard Template (STL) Library containers and algorithms on a foundation of a comprehensive examination of std::vector. We will start with introducing std::vector, contrasting it with traditional C-style arrays, and covering essential operations such as initializing, accessing, and modifying elements. We then advance to the intricacies of iterators, revealing their types and uses in std::vector operations and the elegance of range-based for loops. Memory management is demystified by constructing an understanding of optimizing the allocation and deallocation of resources, including an introduction to creating custom allocators. The section then builds into applying algorithms to sort, search, and manipulate vector contents efficiently, emphasizing the role of custom comparators and the importance of understanding iterator invalidation. The final chapter encapsulates the performance considerations and practical applications of std::vector, cementing its status as the default container choice for C++ developers.
This part has the following chapters:
Chapter 1: The Basics of std::vectorChapter 2: Mastering Iterators with std::vectorChapter 3: Mastering Memory and Allocators with std::vectorChapter 4: Mastering Algorithms with std::vectorChapter 5: Making a Case for std::vector