# New Concurrent Hash Maps for C++

DevFeed: [New Concurrent Hash Maps for C++](<https://devfeed.tech/articles/new-concurrent-hash-maps-for-c-21004.md>)

Original publisher: [Read original article](<https://preshing.com/20160201/new-concurrent-hash-maps-for-cpp>)

Author: Jeff Preshing

Published: 2016-02-01T13:30:00Z

Content type: article

Language: en

Sources: [Jeff Preshing](<https://devfeed.tech/sources/jeff-preshing.md>)

Topics: [C++](<https://devfeed.tech/topics/c-plus-plus.md>), [Concurrency](<https://devfeed.tech/topics/concurrency.md>), [Data structures](<https://devfeed.tech/topics/data-structures.md>), [Library](<https://devfeed.tech/topics/library.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [CMake](<https://devfeed.tech/topics/cmake.md>), [Ubuntu](<https://devfeed.tech/topics/ubuntu.md>), [Windows](<https://devfeed.tech/topics/windows.md>), [iOS](<https://devfeed.tech/topics/ios.md>), [Java](<https://devfeed.tech/topics/java.md>)

Tags: [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [cmake](<https://devfeed.tech/tags/cmake.md>), [code](<https://devfeed.tech/tags/code.md>), [concurrent](<https://devfeed.tech/tags/concurrent.md>), [data](<https://devfeed.tech/tags/data.md>), [dependencies](<https://devfeed.tech/tags/dependencies.md>), [efficiency](<https://devfeed.tech/tags/efficiency.md>), [ios](<https://devfeed.tech/tags/ios.md>), [java](<https://devfeed.tech/tags/java.md>), [lock-free](<https://devfeed.tech/tags/lock-free.md>), [lookup](<https://devfeed.tech/tags/lookup.md>), [map](<https://devfeed.tech/tags/map.md>), [os](<https://devfeed.tech/tags/os.md>), [platforms](<https://devfeed.tech/tags/platforms.md>), [programming](<https://devfeed.tech/tags/programming.md>), [structure](<https://devfeed.tech/tags/structure.md>), [thread](<https://devfeed.tech/tags/thread.md>), [ubuntu](<https://devfeed.tech/tags/ubuntu.md>), [windows](<https://devfeed.tech/tags/windows.md>)

## AI overview

The article introduces Junction, a BSD-licensed C++ library containing concurrent hash maps designed for lock-free, multi-threaded operations. It describes the Linear, Leapfrog, and Grampa map variants, their resizing and lookup strategies, platform support, and atomic operations.

## Source excerpt

A map is a data structure that maps a collection of keys to a collection of values. It's a common concept in computer programming. You typically manipulate maps using functions such as find, insert and erase. A concurrent map is one that lets you call some of those functions concurrently - even in combinations where the map is modified. If it lets you call insert from multiple threads, with no mutual exclusion, it's a concurrent map. If it lets you call insert while another thread is calling find, with no mutual exclusion, it's a concurrent map. Other combinations might be allowed, too. Traditional maps, such as std::map and std::unordered_map, don't allow that. Today I'm releasing Junction, a C++ library that contains several new concurrent maps. It's BSD-licensed, so you can use the source code freely in any project, for any purpose. On my Core i7-5930K, Junction's two fastest maps outperform all other concurrent maps. They come in three flavors: Junction's Linear map is similar to the simple lock-free hash table I published a while ago, except that it also supports resizing, deleting entries, and templated key/value types. It was inspired by Cliff Click's non-blocking hash map in Java, but has a few differences. Junction's Leapfrog map is similar to Linear, except that it uses a probing strategy loosely based on hopscotch hashing. This strategy improves lookup efficiency when the table is densely populated. Leapfrog scales better than Linear because it modifies shared state far less frequently. Junction's Grampa map is similar to Leapfrog, except that at high populations, the map gets split into a set of smaller, fixed-size Leapfrog tables. Whenever one of those tables overflows, it gets split into two new tables instead of resizing the entire map. Junction aims to support as many platforms as possible. So far, it's been tested on Windows, Ubuntu, OS X and iOS. Its main dependencies are CMake and a companion library called Turf. Turf is an abstraction layer over