BloombergLP::bdlcc::StripedUnorderedMap

Fully thread-safe hash map from KEY to VALUE, partitioned into stripes.

Synopsis

Declared in <bdlcc_stripedunorderedmap.h>

template<
    class KEY,
    class VALUE,
    class HASH = bsl::hash<KEY>,
    class EQUAL = bsl::equal_to<KEY>>
class StripedUnorderedMap;

Description

This class template defines a fully thread-safe container that provides a mapping from keys (of template parameter type KEY) to their associated mapped values (of template parameter type VALUE).

The buckets of this hash map are guarded by numStripes reader-writer locks, a value specified on construction. Partitioning the buckets among several locks allows greater overall concurrency than a bsl::unordered_map object guarded by a single lock.

The interface is inspired by, but not identical to that of bsl::unordered_map. Notably absent are iterators, which are of limited practicality in the typical use case because they are readily invalidated when the map population is open to modification by multiple threads.

Type Aliases

NameDescription
EraseIfValuePredicate Alias for a predicate that selects values to erase.
KVType Value type of a bulk insert entry.
ReadOnlyVisitorFunction Alias for a read-only visitor over element values.
VisitorFunction Alias for a visitor that may modify element values.

Enums

NameDescription
Unnamed enum Default sizing constants for this map.

Member Functions

NameDescription
StripedUnorderedMap [constructor]Constructors
allocator Return the allocator used by this hash map to supply memory.
bucketCount Return the number of buckets maintained by this hash map.
bucketIndex Return the bucket index where elements with key are inserted.
bucketSize Return the number of elements in the bucket at index.
clear Remove all elements from this hash map. If rehash is in progress, block until it completes.
disableRehash Prevent future rehash until enableRehash is called.
empty Return true if this hash map contains no elements, and false otherwise.
enableRehash Allow rehashing to resume when the load factor is exceeded.
equalFunction Return a copy of the key-equality functor used by this hash map.
erase Erase the element having the specified key.
eraseBulk Erase elements whose keys fall in the range [first, last)].
eraseIf Remove the element with key if predicate holds true.
getValue Load into *value the value for key, if present.
hashFunction Return (a copy of) the unary hash functor used by this hash map. The return function will generate a hash value (of type std::size_t) for a KEY object.
insert insert overloads
insertBulk Insert or update unique keys from the range [first, last)].
isRehashEnabled Return true if rehash is enabled, or false otherwise.
loadFactor Return the current load factor of this hash map.
maxLoadFactor Return the maximum load factor allowed for this hash map.
numStripes Return the number of stripes in the hash.
rehash Recreate this hash map with at least numBuckets buckets.
setComputedValue Invoke visitor on the value for key, inserting a default if absent.
setValue setValue overloads
size Return the current number of elements in this hash map.
update Call visitor on the element having key, if present.
visit visit overloads
visitReadOnly visitReadOnly overloads