Associative Containers

C++ Core Guidelines: Avoid Bounds Errors

When you access an element outside a container of the STL, the result is not so promising. Your effect may be an error or undefined behavior. Undefined behavior means all bets are open.

Read more
Views: 23407

More special Friends with std::map and std::unordered_map

Modern C++ has eight associative containers, but your special friends should be std::map and std::unordered_map. Why? Let me explain it in this post.

Read more
Views: 29017

C++ Core Guidelines: More about Control Structures

My last German post C++ Core Guidelines: To Switch or not to Switch, that is the Question got a lot of attention. To use a hash table instead of a switch statement seems to be a highly emotional topic. So I change my original plan. Today, I will present different kinds of control structures. I will start with the if and switch statements, continue with the hash table, and end with dynamic and static polymorphism. Additionally, I will mark a few remarks about performance and maintainability. 

Read more
Views: 26135

C++17: Improved Associative Containers and Uniform Container Access

C++11 has eight associative containers. With C++17, you can more comfortably insert new elements into them, merge existing associative containers, or move elements from one container into another if they are similar. But that is not all. The access to the associative and sequential containers was unified.

Read more
Views: 37957

Functional in C++11 and C++14: Dispatch Table and Generic Lambdas

My favorite example, the dispatch table, shows how nicely the features in modern C++ work together. A dispatch table is a table of pointers to functions. In my case, it is a table of handles for polymorphic function wrappers.

Read more
Views: 78436

Buckets, Capacity, and Load Factor

The hash function maps a potentially infinite number of keys on a finite number of buckets. What is the strategy of the C++ runtime and how can you tailor it to your needs, that is what this article is all about.

Read more
Views: 48637

Hash Functions

The hash function is responsible for the unordered associative containers' constant access time (best cast). As ever, C++ offers many ways to adjust the behavior of the hash functions. On the one hand, C++ has a lot of different hash functions; on the other hand, you can define your hash function. You can even adjust the number of buckets.

Read more
Views: 122410

Associative Containers - A simple Performance Comparison

Before I take a deeper look insight the interface of the hash tables - officially called unordered associative containers - I will first compare the performance of the associative containers. The best candidates are std::unordered_map and the ordered pendant std::map because both are used most frequently.

Read more
Views: 30979

Hash Tables

We missed the hash table in C++ for a long time. They promise to have constant access time. C++11 has hash tables in four variations. The official name is unordered associative containers. Unofficially, they are called dictionaries or just simple associative arrays. 

Read more
Views: 152065

Stay Informed about my Mentoring

 

Mentoring

English Books

Course: Modern C++ Concurrency in Practice

Course: C++ Standard Library including C++14 & C++17

Course: Embedded Programming with Modern C++

Course: Generic Programming (Templates)

Course: C++ Fundamentals for Professionals

Course: The All-in-One Guide to C++20

Course: Master Software Design Patterns and Architecture in C++

Subscribe to the newsletter (+ pdf bundle)

All tags

Blog archive

Source Code

Visitors

Today 4009

Yesterday 4371

Week 39816

Month 169941

All 12057707

Currently are 220 guests and no members online

Kubik-Rubik Joomla! Extensions

Latest comments