Fixed‐size, lock‐free hash array and building block for AtomicHashMap.

Synopsis

Declared in <folly/AtomicHashArray.h>

template<
    class KeyT,
    class ValueT,
    class HashFcn = std::hash<KeyT>,
    class EqualFcn = std::equal_to<KeyT>,
    class Allocator = std::allocator<char>,
    class ProbeFcn = AtomicHashArrayLinearProbeFcn,
    class KeyConvertFcn = Identity>
class AtomicHashArray;

Description

Provides the core lock‐free functionality but cannot grow past its initialization size. Keys must be atomically compare‐and‐swappable integer or pointer types. See AtomicHashMap for the growable container built on top of this one.

Types

Name

Description

Config

Named parameters used to configure create.

aha_iterator

Random‐access iterator over the elements of an AtomicHashArray.

Type Aliases

Name

Description

SmartPtr

A unique_ptr to an AtomicHashArray with a custom deleter.

const_iterator

A read‐only iterator over the elements of the map.

const_pointer

A const pointer to an element.

const_reference

A const reference to an element.

difference_type

A signed integral type used for distances between iterators.

hasher

The hash function type used to hash keys.

iterator

A mutable iterator over the elements of the map.

key_convert

The functor type used to convert a lookup key into a stored key.

key_equal

The equality comparison type used to compare keys.

key_type

The type of the keys stored in the map.

mapped_type

The type of the mapped values.

pointer

A pointer to an element.

reference

A reference to an element.

size_type

An unsigned integral type used for sizes and capacities.

value_type

The type of the elements stored in the map.

Member Functions

Name

Description

begin

begin overloads

clear

Clear all keys and values in the map and reset all counters.

emplace

Insert an element, constructing the value in place.

empty

Check whether the map is empty.

end

end overloads

erase

Erase the element with the given key.

find

Find the element with the given key.

findAt

Access an element directly by slot index.

getEntryCountThreadCacheSize

Return the per‐thread cache size for the entry counters.

insert

insert overloads

makeIter

makeIter overloads

maxLoadFactor

Return the maximum load factor allowed for this map.

setEntryCountThreadCacheSize

Set the per‐thread cache size for the entry counters.

size

Return the exact number of elements in the map.

Static Member Functions

Name

Description

create

Create an AtomicHashArray.

destroy

Destroy an AtomicHashArray created with create.

Data Members

Name

Description

capacity_

The total number of slots in the underlying array.

kEmptyKey_

The sentinel key value that marks an empty slot.

kErasedKey_

The sentinel key value that marks an erased slot.

kLockedKey_

The sentinel key value that marks a slot locked during insertion.

maxEntries_

The maximum number of entries allowed before the map is considered full.

Friends

Name

Description

folly::AtomicHashMap

Lock‐free, growable hash map built on top of AtomicHashArray.

Created with MrDocs