BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL > Class Template Reference

#include <bdlcc_stripedunorderedcontainerimpl.h>

Public Types

enum  { k_DEFAULT_NUM_BUCKETS = 16 , k_DEFAULT_NUM_STRIPES = 4 }
 
typedef StripedUnorderedContainerImpl_Node< KEY, VALUE > Node
 Node in a bucket.
 
typedef bsl::pair< KEY, VALUE > KVType
 Value type of a bulk insert entry.
 
typedef bsl::function< bool(VALUE *, const KEY &)> VisitorFunction
 
typedef bsl::function< bool(const VALUE &, const KEY &)> ReadOnlyVisitorFunction
 
typedef bsl::function< bool(const VALUE &)> EraseIfValuePredicate
 

Public Member Functions

 StripedUnorderedContainerImpl (bsl::size_t numInitialBuckets=k_DEFAULT_NUM_BUCKETS, bsl::size_t numStripes=k_DEFAULT_NUM_STRIPES, bslma::Allocator *basicAllocator=0)
 
 ~StripedUnorderedContainerImpl ()
 Destroy this hash map. This method is not thread-safe.
 
void clear ()
 
void disableRehash ()
 Prevent rehash until the enableRehash method is called.
 
void enableRehash ()
 
bsl::size_t eraseAll (const KEY &key)
 
bsl::size_t eraseAllIf (const KEY &key, const EraseIfValuePredicate &predicate)
 
template<class RANDOM_ITER >
bsl::size_t eraseBulkAll (RANDOM_ITER first, RANDOM_ITER last)
 
template<class RANDOM_ITER >
bsl::size_t eraseBulkFirst (RANDOM_ITER first, RANDOM_ITER last)
 
bsl::size_t eraseFirst (const KEY &key)
 
bsl::size_t eraseFirstIf (const KEY &key, const EraseIfValuePredicate &predicate)
 
void insertAlways (const KEY &key, const VALUE &value)
 
void insertAlways (const KEY &key, bslmf::MovableRef< VALUE > value)
 
template<class RANDOM_ITER >
void insertBulkAlways (RANDOM_ITER first, RANDOM_ITER last)
 
template<class RANDOM_ITER >
bsl::size_t insertBulkUnique (RANDOM_ITER first, RANDOM_ITER last)
 
bsl::size_t insertUnique (const KEY &key, const VALUE &value)
 
bsl::size_t insertUnique (const KEY &key, bslmf::MovableRef< VALUE > value)
 
void maxLoadFactor (float newMaxLoadFactor)
 
void rehash (bsl::size_t numBuckets)
 
int setComputedValueAll (const KEY &key, const VisitorFunction &visitor)
 
int setComputedValueFirst (const KEY &key, const VisitorFunction &visitor)
 
bsl::size_t setValueAll (const KEY &key, const VALUE &value)
 
bsl::size_t setValueFirst (const KEY &key, const VALUE &value)
 
bsl::size_t setValueFirst (const KEY &key, bslmf::MovableRef< VALUE > value)
 
int update (const KEY &key, const VisitorFunction &visitor)
 
int visit (const VisitorFunction &visitor)
 
int visit (const KEY &key, const VisitorFunction &visitor)
 
bsl::size_t bucketIndex (const KEY &key) const
 
bsl::size_t bucketCount () const
 
bsl::size_t bucketSize (bsl::size_t index) const
 
bool canRehash () const
 
bool empty () const
 
EQUAL equalFunction () const
 
bsl::size_t getValue (VALUE *value, const KEY &key) const
 
bsl::size_t getValue (bsl::vector< VALUE > *valuesPtr, const KEY &key) const
 
bsl::size_t getValue (std::vector< VALUE > *valuesPtr, const KEY &key) const
 
HASH hashFunction () const
 
bool isRehashEnabled () const
 Return true if rehash is enabled, or false otherwise.
 
float loadFactor () const
 
float maxLoadFactor () const
 
bsl::size_t numStripes () const
 Return the number of stripes in the hash.
 
int visitReadOnly (const ReadOnlyVisitorFunction &visitor) const
 
int visitReadOnly (const KEY &key, const ReadOnlyVisitorFunction &visitor) const
 
bsl::size_t size () const
 Return the current number of elements in this hash.
 
bslma::Allocatorallocator () const
 

Friends

class StripedUnorderedContainerImpl_TestUtil< KEY, VALUE, HASH, EQUAL >
 
class StripedUnorderedContainerImpl_LockElement
 

Detailed Description

template<class KEY, class VALUE, class HASH, class EQUAL>
class bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >

This class implements the logic for a striped hash multimap with logic that supports a (unique) map as a special case.

See bdlcc_stripedunorderedcontainerimpl

Member Typedef Documentation

◆ EraseIfValuePredicate

template<class KEY , class VALUE , class HASH , class EQUAL >
typedef bsl::function<bool(const VALUE&)> bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::EraseIfValuePredicate

An alias to a function meeting the following contract:

bool eraseIfValuePredicate(const VALUE& value);
// Return 'true' if the specified 'value' is to be removed from
// the container, and 'false' otherwise. Note that this
// functor can *not* change the values associated with 'value'.

◆ KVType

template<class KEY , class VALUE , class HASH , class EQUAL >
typedef bsl::pair<KEY, VALUE> bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::KVType

◆ Node

template<class KEY , class VALUE , class HASH , class EQUAL >
typedef StripedUnorderedContainerImpl_Node<KEY, VALUE> bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::Node

◆ ReadOnlyVisitorFunction

template<class KEY , class VALUE , class HASH , class EQUAL >
typedef bsl::function<bool (const VALUE&, const KEY&)> bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::ReadOnlyVisitorFunction

An alias to a function meeting the following contract:

bool visitorFunction(const VALUE& value, const KEY& key);
// Visit the specified 'value' attribute associated with the
// specified 'key'. Return 'true' if this function may be
// called on additional elements, and 'false' otherwise (i.e.,
// if no other elements should be visited). Note that this
// functor can *not* change the values associated with 'key'
// and 'value'.

◆ VisitorFunction

template<class KEY , class VALUE , class HASH , class EQUAL >
typedef bsl::function<bool (VALUE *, const KEY&)> bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::VisitorFunction

An alias to a function meeting the following contract:

bool visitorFunction(VALUE *value, const KEY& key);
// Visit the specified 'value' attribute associated with the
// specified 'key'. Return 'true' if this function may be
// called on additional elements, and 'false' otherwise (i.e.,
// if no other elements should be visited). Note that this
// functor can change the value associated with 'key'.

Member Enumeration Documentation

◆ anonymous enum

template<class KEY , class VALUE , class HASH , class EQUAL >
anonymous enum
Enumerator
k_DEFAULT_NUM_BUCKETS 
k_DEFAULT_NUM_STRIPES 

Constructor & Destructor Documentation

◆ StripedUnorderedContainerImpl()

template<class KEY , class VALUE , class HASH , class EQUAL >
bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::StripedUnorderedContainerImpl ( bsl::size_t  numInitialBuckets = k_DEFAULT_NUM_BUCKETS,
bsl::size_t  numStripes = k_DEFAULT_NUM_STRIPES,
bslma::Allocator basicAllocator = 0 
)
inlineexplicit

Create an empty StripedUnorderedContainerImpl object, a fully thread-safe hash map where access is divided into "stripes" (a group of buckets protected by a reader-write mutex). Optionally specify numInitialBuckets and numStripes which define the minimum number of buckets and the (fixed) number of stripes in this map. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. The hash map has rehash enabled.

◆ ~StripedUnorderedContainerImpl()

template<class KEY , class VALUE , class HASH , class EQUAL >
bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::~StripedUnorderedContainerImpl ( )
inline

Member Function Documentation

◆ allocator()

template<class KEY , class VALUE , class HASH , class EQUAL >
bslma::Allocator * bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::allocator ( ) const
inline

Return the allocator used by this hash map to supply memory. Note that if no allocator was supplied at construction the default allocator installed at that time is used.

◆ bucketCount()

template<class KEY , class VALUE , class HASH , class EQUAL >
bsl::size_t bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::bucketCount ( ) const
inline

Return the number of buckets in the array of buckets maintained by this hash map. Note that unless rehash is disabled, the value returned may be obsolete by the time it is received.

◆ bucketIndex()

template<class KEY , class VALUE , class HASH , class EQUAL >
bsl::size_t bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::bucketIndex ( const KEY &  key) const
inline

Return the index of the bucket, in the array of buckets maintained by this hash map, where elements having the specified key are inserted. Note that unless rehash is disabled, the value returned may be obsolete at the time it is returned.

◆ bucketSize()

template<class KEY , class VALUE , class HASH , class EQUAL >
bsl::size_t bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::bucketSize ( bsl::size_t  index) const
inline

Return the number of elements contained in the bucket at the specified index in the array of buckets maintained by this hash map. The behavior is undefined unless 0 <= index < bucketCount().

◆ canRehash()

template<class KEY , class VALUE , class HASH , class EQUAL >
bool bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::canRehash ( ) const
inline

Return true if rehash is enabled and rehash is not in progress, and false otherwise.

◆ clear()

template<class KEY , class VALUE , class HASH , class EQUAL >
void bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::clear ( )
inline

Remove all elements from this striped hash map. If rehash is in progress, block until it completes.

◆ disableRehash()

template<class KEY , class VALUE , class HASH , class EQUAL >
void bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::disableRehash ( )
inline

◆ empty()

template<class KEY , class VALUE , class HASH , class EQUAL >
bool bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::empty ( ) const
inline

Return true if this hash map contains no elements, and false otherwise.

◆ enableRehash()

template<class KEY , class VALUE , class HASH , class EQUAL >
void bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::enableRehash ( )
inline

Allow rehash. If conditions warrant, rehash will be started by the next method call that observes the load factor is exceeded (see {Concurrent Rehash}). Note that calling maxLoadFactor(maxLoadFactor()) (i.e., setting the maximum load factor to its current value) will trigger a rehash if needed but otherwise does not change the hash map.

◆ equalFunction()

template<class KEY , class VALUE , class HASH , class EQUAL >
EQUAL bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::equalFunction ( ) const
inline

Return (a copy of) the key-equality functor used by this hash map that returns true if two KEY objects have the same value, and false otherwise.

◆ eraseAll()

template<class KEY , class VALUE , class HASH , class EQUAL >
bsl::size_t bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::eraseAll ( const KEY &  key)
inline

Erase from this hash map the elements having the specified key. Return the number of elements erased.

◆ eraseAllIf()

template<class KEY , class VALUE , class HASH , class EQUAL >
bsl::size_t bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::eraseAllIf ( const KEY &  key,
const EraseIfValuePredicate predicate 
)
inline

Erase from this hash map the elements having the specified key for which the specified predicate holds true. Return the number of elements erased.

◆ eraseBulkAll()

template<class KEY , class VALUE , class HASH , class EQUAL >
template<class RANDOM_ITER >
bsl::size_t bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::eraseBulkAll ( RANDOM_ITER  first,
RANDOM_ITER  last 
)
inline

Erase from this hash map elements in this hash map having any of the values in the keys contained between the specified first (inclusive) and last (exclusive) random-access iterators. The iterators provide read access to a sequence of KEY objects. All erasures are done by the calling thread and the order of erasure is not specified. Return the number of elements removed. The behavior is undefined unless first <= last. Note that the map may not have an element for every value in keys.

◆ eraseBulkFirst()

template<class KEY , class VALUE , class HASH , class EQUAL >
template<class RANDOM_ITER >
bsl::size_t bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::eraseBulkFirst ( RANDOM_ITER  first,
RANDOM_ITER  last 
)
inline

Erase from this hash map elements in this hash map having any of the values in the keys contained between the specified first (inclusive) and last (exclusive) random-access iterators. The iterators provide read access to a sequence of KEY objects. If there are multiple elements for any key value, erase just the first such element found. All erasures are done by the calling thread and the order of erasure is not specified. Return the number of elements removed. The behavior is undefined unless first <= last. Note that the map may not have an element for every value in keys.

◆ eraseFirst()

template<class KEY , class VALUE , class HASH , class EQUAL >
bsl::size_t bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::eraseFirst ( const KEY &  key)
inline

Erase from this hash map the first element (of possibly many) found to the specified key. Return the number of elements erased. Note that method is more performant than eraseAll when there is one element having key.

◆ eraseFirstIf()

template<class KEY , class VALUE , class HASH , class EQUAL >
bsl::size_t bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::eraseFirstIf ( const KEY &  key,
const EraseIfValuePredicate predicate 
)
inline

Erase from this hash map the first element with specified key (of possibly many) found, for which the specified predicate holds true. Return the number of elements erased.

◆ getValue() [1/3]

template<class KEY , class VALUE , class HASH , class EQUAL >
bsl::size_t bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::getValue ( bsl::vector< VALUE > *  valuesPtr,
const KEY &  key 
) const
inline

◆ getValue() [2/3]

template<class KEY , class VALUE , class HASH , class EQUAL >
bsl::size_t bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::getValue ( std::vector< VALUE > *  valuesPtr,
const KEY &  key 
) const
inline

◆ getValue() [3/3]

template<class KEY , class VALUE , class HASH , class EQUAL >
bsl::size_t bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::getValue ( VALUE *  value,
const KEY &  key 
) const
inline

Load, into the specified *value, the value attribute of the first element (of possibly many elements) found in this hash map having the specified key. Return 1 on success, and 0 if key does not exist in this hash. Note that the return value equals the number of values returned. Also note that, when there are multiple elements having key, the selection of "first" is implementation specific and subject to change.

◆ hashFunction()

template<class KEY , class VALUE , class HASH , class EQUAL >
HASH bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::hashFunction ( ) const
inline

Return (a copy of) the unary hash functor used by this hash map to generate a hash value (of type std::size_t) for a KEY object.

◆ insertAlways() [1/2]

template<class KEY , class VALUE , class HASH , class EQUAL >
void bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::insertAlways ( const KEY &  key,
bslmf::MovableRef< VALUE >  value 
)
inline

Insert into this hash map an element having the specified key and the specified move-insertable value. The value object is left in a valid but unspecified state. If value is allocator-enabled and allocator() != value.allocator() this operation may cost as much as a copy. Note that other elements having the same key may exist in this hash map.

◆ insertAlways() [2/2]

template<class KEY , class VALUE , class HASH , class EQUAL >
void bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::insertAlways ( const KEY &  key,
const VALUE &  value 
)
inline

Insert into this hash map an element having the specified key and value. Note that other elements having the same key may exist in this hash map.

◆ insertBulkAlways()

template<class KEY , class VALUE , class HASH , class EQUAL >
template<class RANDOM_ITER >
void bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::insertBulkAlways ( RANDOM_ITER  first,
RANDOM_ITER  last 
)
inline

Insert into this hash map elements having the key-value pairs obtained between the specified first (inclusive) and last (exclusive) random-access iterators. The iterators provide read access to a sequence of bsl::pair<KEY, VALUE> objects. All insertions are done by the calling thread and the order of insertion is not specified. The behavior is undefined unless first <= last.

◆ insertBulkUnique()

template<class KEY , class VALUE , class HASH , class EQUAL >
template<class RANDOM_ITER >
bsl::size_t bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::insertBulkUnique ( RANDOM_ITER  first,
RANDOM_ITER  last 
)
inline

Insert into this hash map elements having the key-value pairs obtained between the specified first (inclusive) and last (exclusive) random-access iterators. The iterators provide read access to a sequence of bsl::pair<KEY, VALUE> objects. If an element having one of the keys already exists in this hash map, set the value attribute to the corresponding value from data. All insertions are done by the calling thread and the order of insertion is not specified. Return the number of elements inserted. The behavior is undefined unless first <= last.

◆ insertUnique() [1/2]

template<class KEY , class VALUE , class HASH , class EQUAL >
bsl::size_t bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::insertUnique ( const KEY &  key,
bslmf::MovableRef< VALUE >  value 
)
inline

Insert into this hash map an element having the specified key and the specified move-insertable value. If key already exists in this hash map, the value attribute of that element is set to value. Return 1 if an element is inserted, and 0 if an existing element is updated. The value object is left in a valid but unspecified state. If value is allocator-enabled and allocator() != value.allocator() this operation may cost as much as a copy. Note that the return value equals the number of elements inserted.

◆ insertUnique() [2/2]

template<class KEY , class VALUE , class HASH , class EQUAL >
bsl::size_t bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::insertUnique ( const KEY &  key,
const VALUE &  value 
)
inline

Insert into this hash map an element having the specified key and value. If key already exists in this hash map, the value attribute of that element is set to value. Return 1 if an element is inserted, and 0 if an existing element is updated. Note that the return value equals the number of elements inserted.

◆ isRehashEnabled()

template<class KEY , class VALUE , class HASH , class EQUAL >
bool bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::isRehashEnabled ( ) const
inline

◆ loadFactor()

template<class KEY , class VALUE , class HASH , class EQUAL >
float bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::loadFactor ( ) const
inline

Return the current quotient of the size of this hash map and the number of buckets. Note that the load factor is a measure of container "fullness"; that is, a high load factor typically implies many collisions (many elements landing in the same bucket) and that decreases performance.

◆ maxLoadFactor() [1/2]

template<class KEY , class VALUE , class HASH , class EQUAL >
float bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::maxLoadFactor ( ) const
inline

Return the maximum load factor allowed for this hash map. If an insert operation would cause the load factor to exceed the maxLoadFactor() and rehashing is enabled, then that insert increases the number of buckets and rehashes the elements of the container into that larger set of buckets.

◆ maxLoadFactor() [2/2]

template<class KEY , class VALUE , class HASH , class EQUAL >
void bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::maxLoadFactor ( float  newMaxLoadFactor)
inline

Set the maximum load factor of this hash map to the specified newMaxLoadFactor. If newMaxLoadFactor < loadFactor(), this operation will cause an immediate rehash; otherwise, this operation has a constant-time cost. The rehash will increase the number of buckets by a power of 2. The behavior is undefined unless 0 < newMaxLoadFactor.

◆ numStripes()

template<class KEY , class VALUE , class HASH , class EQUAL >
bsl::size_t bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::numStripes ( ) const
inline

◆ rehash()

template<class KEY , class VALUE , class HASH , class EQUAL >
void bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::rehash ( bsl::size_t  numBuckets)

Recreate this hash map to one having at least the specified numBuckets. This operation is a no-op if any of the following are true: 1) rehash is disabled; 2) numBuckets less or equals the current number of buckets. See {Rehash}.

rehashed data in a new set of buckets.

◆ setComputedValueAll()

template<class KEY , class VALUE , class HASH , class EQUAL >
int bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::setComputedValueAll ( const KEY &  key,
const VisitorFunction visitor 
)
inline

Serially invoke the specified visitor passing the specified key, and the address of the value of each element in this hash map having key. If key is not in the map, value will be default constructed. That is, for each (key, value) found, invoke:

bool visitor(VALUE *value, const Key& key);

If no element in the map has key, insert (key, VALUE()) and invoke visitor with value pointing to the defsult constructed value. Return the number of elements visited or the negation of that value if visitations stopped because visitor returned false. visitor, when invoked, has exclusive access (i.e., write access) to each element during each invocation. The behavior is undefined if hash map manipulators and getValue* methods are invoked from within visitor, as it may lead to a deadlock. Note that the setComputedValueFirst method is more performant than the when the hash map contains a single element for key. Also note that a return value of 0 implies that an element was inserted.

◆ setComputedValueFirst()

template<class KEY , class VALUE , class HASH , class EQUAL >
int bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::setComputedValueFirst ( const KEY &  key,
const VisitorFunction visitor 
)
inline

Invoke the specified visitor passing the specified key, and the address of the value attribute of the first element (of possibly many elements) found in this hash map having key. If key is not in the map, value will be default constructed. That is, for (key, value), invoke:

bool visitor(VALUE *value, const Key& key);

If no element in the map has key, insert (key, VALUE()) and invoke visitor with value pointing to the defsult constructed value. Return 1 if key was found and visitor returned true, 0 if key was not found, and -1 if key was found and visitor returned false. visitor, when invoked, has exclusive access (i.e., write access) to the element. The behavior is undefined if hash map manipulators and getValue* methods are invoked from within visitor, as it may lead to a deadlock. Note that the return value equals the number of elements inserted. Also note that, when there are multiple elements having key, the selection of "first" is implementation specific and subject to change. Also note that this method is more performant than the setComputedValueAll method when the hash map contains a single element for key. Also note that a return value of 0 implies that an element was inserted.

◆ setValueAll()

template<class KEY , class VALUE , class HASH , class EQUAL >
bsl::size_t bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::setValueAll ( const KEY &  key,
const VALUE &  value 
)
inline

Set the value attribute of every element in this hash map having the specified key to the specified value. If no such such element exists, insert (key, value). Return the number of elements found with key. Note that if no elements were found, and a new value was inserted, 0 is returned.

◆ setValueFirst() [1/2]

template<class KEY , class VALUE , class HASH , class EQUAL >
bsl::size_t bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::setValueFirst ( const KEY &  key,
bslmf::MovableRef< VALUE >  value 
)
inline

Set the value attribute of the element in this hash map having the specified key to the specified value. If no such element exists, insert (key, value). If there are multiple elements in this hash map having key then set the value of the first such element found. Return the number of elements found having key. Note that if no elements were found, and a new value was inserted, 0 is returned. Also note that, when there are multiple elements having key, the selection of "first" is unspecified and subject to change.

◆ setValueFirst() [2/2]

template<class KEY , class VALUE , class HASH , class EQUAL >
bsl::size_t bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::setValueFirst ( const KEY &  key,
const VALUE &  value 
)
inline

Set the value attribute of the first element in this hash map (of possibly many) found to have the specified key to the specified value. If no such such element exists, insert (key, value). Return the number of elements found with key. Note that if no elements were found, and a new value was inserted, 0 is returned. Also note that this method is more performant than setValueAll when there is one element having key in the hash map.

◆ size()

template<class KEY , class VALUE , class HASH , class EQUAL >
bsl::size_t bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::size ( ) const
inline

◆ update()

template<class KEY , class VALUE , class HASH , class EQUAL >
int bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::update ( const KEY &  key,
const VisitorFunction visitor 
)
inline
Deprecated:
Use visit(key, visitor) instead.

Serially call the specified visitor on each element (if one exists) in this hash map having the specified key until every such element has been updated or visitor returns false. That is, for (key, value), invoke:

bool visitor(&value, key);

Return the number of elements visited or the negation of that value if visitations stopped because visitor returned false. visitor has exclusive access (i.e., write access) to each element for duration of each invocation. The behavior is undefined if hash map manipulators and getValue* methods are invoked from within visitor, as it may lead to a deadlock.

◆ visit() [1/2]

template<class KEY , class VALUE , class HASH , class EQUAL >
int bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::visit ( const KEY &  key,
const VisitorFunction visitor 
)
inline

Serially call the specified visitor on each element (if one exists) in this hash map having the specified key until every such element has been updated or visitor returns false. That is, for (key, value), invoke:

bool visitor(&value, key);

Return the number of elements visited or the negation of that value if visitations stopped because visitor returned false. visitor has exclusive access (i.e., write access) to each element for duration of each invocation. The behavior is undefined if hash map manipulators and getValue* methods are invoked from within visitor, as it may lead to a deadlock.

◆ visit() [2/2]

template<class KEY , class VALUE , class HASH , class EQUAL >
int bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::visit ( const VisitorFunction visitor)

Call the specified visitor (in an unspecified order) on the elements in this hash table until each element has been visited or visitor returns false. That is, for (key, value), invoke:

bool visitor(&value, key);

Return the number of elements visited or the negation of that value if visitations stopped because visitor returned false. visitor has exclusive access (i.e., write access) to each element for duration of each invocation. Every element present in this hash map at the time visit is invoked will be visited unless it is removed before visitor is called for that element. Each visitation is done by the calling thread and the order of visitation is not specified. Elements inserted during the execution of visit may or may not be visited. The behavior is undefined if hash map manipulators and getValue* methods are invoked from within visitor, as it may lead to a deadlock. Note that visitor can change the value of the visited elements.

◆ visitReadOnly() [1/2]

template<class KEY , class VALUE , class HASH , class EQUAL >
int bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::visitReadOnly ( const KEY &  key,
const ReadOnlyVisitorFunction visitor 
) const
inline

Serially call the specified visitor on each element (if one exists) in this hash map having the specified key until every such element has been visitd or visitor returns false. That is, for (key, value), invoke:

bool visitor(value, key);

Return the number of elements visited or the negation of that value if visitations stopped because visitor returned false. visitor has read-only access to each element for duration of each invocation. The behavior is undefined if hash map manipulators are invoked from within visitor, as it may lead to a deadlock.

◆ visitReadOnly() [2/2]

template<class KEY , class VALUE , class HASH , class EQUAL >
int bdlcc::StripedUnorderedContainerImpl< KEY, VALUE, HASH, EQUAL >::visitReadOnly ( const ReadOnlyVisitorFunction visitor) const

Call the specified visitor (in an unspecified order) on the elements in this hash table until each element has been visited or visitor returns false. That is, for (key, value), invoke:

bool visitor(value, key);

Return the number of elements visited or the negation of that value if visitations stopped because visitor returned false. visitor has read-only access to each element for duration of each invocation. Every element present in this hash map at the time visit is invoked will be visited unless it is removed before visitor is called for that element. Each visitation is done by the calling thread and the order of visitation is not specified. The behavior is undefined if hash map manipulators are invoked from within visitor, as it may lead to a deadlock. Note that visitor can not change the value of the visited elements.

Friends And Related Symbol Documentation

◆ StripedUnorderedContainerImpl_LockElement

template<class KEY , class VALUE , class HASH , class EQUAL >
friend class StripedUnorderedContainerImpl_LockElement
friend

◆ StripedUnorderedContainerImpl_TestUtil< KEY, VALUE, HASH, EQUAL >

template<class KEY , class VALUE , class HASH , class EQUAL >
friend class StripedUnorderedContainerImpl_TestUtil< KEY, VALUE, HASH, EQUAL >
friend

The documentation for this class was generated from the following file: