Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Expert C++ - Second Edition

You're reading from  Expert C++ - Second Edition

Product type Book
Published in Aug 2023
Publisher Packt
ISBN-13 9781804617830
Pages 604 pages
Edition 2nd Edition
Languages
Authors (5):
Marcelo Guerra Hahn Marcelo Guerra Hahn
Profile icon Marcelo Guerra Hahn
Araks Tigranyan Araks Tigranyan
Profile icon Araks Tigranyan
John Asatryan John Asatryan
Profile icon John Asatryan
Vardan Grigoryan Vardan Grigoryan
Profile icon Vardan Grigoryan
Shunguang Wu Shunguang Wu
Profile icon Shunguang Wu
View More author details

Table of Contents (24) Chapters

Preface Part 1:Under the Hood of C++ Programming
Chapter 1: Building C++ Applications Chapter 2: Beyond Object-Oriented Programming Chapter 3: Understanding and Designing Templates Chapter 4: Template Meta Programming Chapter 5: Memory Management and Smart Pointers Part 2: Designing Robust and Efficient Applications
Chapter 6: Digging into Data Structures and Algorithms in STL Chapter 7: Advanced Data Structures Chapter 8: Functional Programming Chapter 9: Concurrency and Multithreading Chapter 10: Designing Concurrent Data Structures Chapter 11: Designing World-Ready Applications Chapter 12: Incorporating Design Patterns in C++ Applications Chapter 13: Networking and Security Chapter 14: Debugging and Testing Chapter 15: Large-Scale Application Design Part 3:C++ in the AI World
Chapter 16: Understanding and Using C++ in Machine Learning Tasks Chapter 17: Using C++ in Data Science Chapter 18: Designing and Implementing a Data Analysis Framework Index Other Books You May Enjoy

Hash functions and strategies that are used to implement them

The hash function is used to convert keys into indexes of an array. The hash function should, in theory, map every potential key to a distinct slot index, but in reality, this is challenging to do.

A hash function that takes a set of items as input and maps each one to a distinct slot is called a perfect hash function. It is feasible to create a perfect hash function if we know the items and the collection won’t change. Unfortunately, there is no methodical way to build a perfect hash function given a random set of elements. Thankfully, we can still gain performance efficiency, even if the hash algorithm is not perfect.

The size of the hash table can be increased in order to include all possible values for the element range, which is one technique to ensure that the hash function is always perfect. This ensures that every component will have a unique slot. Although this is doable for small numbers of items,...

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 $15.99/month. Cancel anytime}