#include <coherence/util/WeakHashMap.hpp>
Inherits SafeHashMap.
That is the use an object as a key in the map will not prevent it from being destroyed if all other non-weak references to it are released.
The time at which the entry associated with the weak key is cleaned up is not guaranteed, it may live in the map for some time. While it is not safe to assume that the map will shrink to its absolute minimum at any point, it is safe to assume that given constant random key insertions the size of the map will initially grow and then stabilize as the keys are reclaimed.
Note: Iterating the entries may yield entries with reclaimed (NULL) keys.
Public Types | ||||||||||
typedef spec::Handle | Handle | |||||||||
WeakHashMap Handle definition. | ||||||||||
typedef spec::View | View | |||||||||
WeakHashMap View definition. | ||||||||||
typedef spec::Holder | Holder | |||||||||
WeakHashMap Holder definition. | ||||||||||
Public Member Functions | ||||||||||
virtual void | compact () | |||||||||
Cleanup any "garbage" entries in the map. | ||||||||||
Protected Member Functions | ||||||||||
WeakHashMap (size32_t cInitialBuckets=17, float32_t flLoadFactor=1.0F, float32_t flGrowthRate=3.0F) | ||||||||||
Construct a thread-safe weak hash map using the specified settings. | ||||||||||
WeakHashMap (const WeakHashMap &that) | ||||||||||
Copy constructor. | ||||||||||
virtual SafeHashMap::Entry::Handle | instantiateEntry (Object::View vKey, Object::Holder ohValue, size32_t nHash) | |||||||||
Factory pattern, initialized with the specified valued.
| ||||||||||
virtual SafeHashMap::Entry::Handle | instantiateEntry (SafeHashMap::Entry::View vThat) | |||||||||
Factory pattern, instantiate an Entry that is either a deep or shalow copy.
| ||||||||||
virtual void | grow () | |||||||||
Resize the bucket array, rehashing all Entries. | ||||||||||
virtual size32_t | shrink (size32_t iBucket, size32_t cEntries) | |||||||||
Shrink the specified bucket. | ||||||||||
Classes | ||||||||||
class | Entry | |||||||||
A map entry (key-value pair). More... |
WeakHashMap | ( | size32_t | cInitialBuckets = 17 , |
|
float32_t | flLoadFactor = 1.0F , |
|||
float32_t | flGrowthRate = 3.0F | |||
) | [protected] |
Construct a thread-safe weak hash map using the specified settings.
cInitialBuckets | the initial number of hash buckets, 0 < n | |
flLoadFactor | the acceptable load factor before resizing occurs, 0 < n, such that a load factor of 1.0 causes resizing when the number of entries exceeds the number of buckets | |
flGrowthRate | the rate of bucket growth when a resize occurs, 0 < n, such that a growth rate of 1.0 will double the number of buckets: bucketcount = bucketcount * (1 + growthrate) |
virtual size32_t shrink | ( | size32_t | iBucket, | |
size32_t | cEntries | |||
) | [protected, virtual] |
Shrink the specified bucket.
iBucket | the bucket to shrink | |
cEntries | the maximum number of entries to shrink by |