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: 36054

Hash Functions

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

Read more
Views: 106286

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 at 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: 21508

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: 107914

Type-Traits: Performance Matters

If you look carefully, you see, type-traits have a big optimization potential. The type-traits support in the first step to analyse the code at the compile-time and in the second step, to optimize the code based on that analysis. How is that possible? Dependent on the type of variable a faster variant of an algorithm will be chosen.

Read more
Views: 14631

constexpr Functions

constexpr functions are functions that can be executed at compile time. Sounds not so thrilling. But it is. Trust me. You can perform with constexpr functions a lot of calculations at compile time. Therefore, the result of the calculation is at runtime as a constant in ROM available. In addition, constexpr functions are implicitly inline.

Read more
Tags: constexpr
Views: 58000

constexpr - Variables and Objects

If you declare a variable as constexpr the compiler will evaluate them at compile time. This holds not only true for built-in types but also for instantiations of user-defined types. There are a few serious restrictions for objects in order to evaluate them at compile time.

 

Read more
Tags: constexpr
Views: 30317

Constant Expressions with constexpr

You can define with the keyword constexpr an expression that can be evaluated at compile time. constexpr can be used for variables, functions, and user-defined types. An expression that is evaluated at compile time has a lot of advantages. For example, constexpr variables and instances of user-defined types are automatically thread-safe and can be stored in ROM; constexpr functions that are evaluated at compile-time, are totally done with their work at run time.

Read more
Tags: constexpr
Views: 13455

inline

Thanks to inline the compiler can replace the function call by the function body. There are two reasons to use inline functions: performance and safety.

Read more
Tags: inline
Views: 16020

The Null Pointer Constant nullptr

The new null pointer nullptr cleans up in C++ with the ambiguity of the number 0 and the macro NULL.

Read more
Tags: nullptr
Views: 29791

My Newest E-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

Subscribe to the newsletter (+ pdf bundle)

Blog archive

Source Code

Visitors

Today 4901

Yesterday 7135

Week 36650

Month 47197

All 6275669

Currently are 165 guests and no members online

Kubik-Rubik Joomla! Extensions

Latest comments