sipxportlib
Version 3.3
|
#include <UtlHashMap.h>
Public Member Functions | |
UtlHashMap () | |
Default Constructor. More... | |
virtual | ~UtlHashMap () |
Destructor. More... | |
virtual UtlHashMap * | clone () const |
Make an off the heap copy of this object. More... | |
UtlContainable * | insertKeyAndValue (UtlContainable *key, UtlContainable *value) |
Inserts a key and value pair into the hash map. More... | |
UtlContainable * | insert (UtlContainable *obj) |
Inserts the designated containable object into the list with a NULL value. More... | |
UtlContainable * | remove (UtlContainable *key) |
Remove the designated key and its associated value. More... | |
UtlContainable * | removeReference (const UtlContainable *key) |
Remove the designated key and its associated value. More... | |
UtlContainable * | removeKeyAndValue (const UtlContainable *key, UtlContainable *&value) |
Remove the designated key and its associated value. More... | |
virtual UtlBoolean | destroy (UtlContainable *key) |
Removes the designated key and its associated value from the map and frees the key and the value (if not NULL) by calling delete. More... | |
virtual void | destroyAll () |
Removes all elements from the hash map and deletes each element. More... | |
virtual void | removeAll () |
Removes all elements from the hash map without deleting the elements. More... | |
UtlContainable * | findValue (const UtlContainable *key) const |
Return the value for a given key or NULL if not found. More... | |
virtual UtlContainable * | find (const UtlContainable *key) const |
Return the designated key if found otherwise NULL. More... | |
size_t | entries () const |
Return the total number of keys in the hash map. More... | |
UtlBoolean | isEmpty () const |
Return true if the hash map is empty (entries() == 0), otherwise false. More... | |
UtlBoolean | contains (const UtlContainable *key) const |
Return true if the hash map includes an entry with the specified key. More... | |
virtual UtlContainableType | getContainableType () const |
Get the ContainableType for the hash bag as a contained object. More... | |
void | copyInto (UtlHashMap &map) const |
Make a copy of all of the items BY POINTER in (*this) instance into the given map. More... | |
OsStatus | deepCopyInto (UtlHashMap &map) const |
size_t | numberOfBuckets () const |
The current number of buckets in the hash. More... | |
Public Member Functions inherited from UtlContainer | |
UtlContainer () | |
virtual | ~UtlContainer () |
virtual unsigned | hash () const |
virtual int | compareTo (const UtlContainable *otherObject) const |
Public Member Functions inherited from UtlContainable | |
virtual | ~UtlContainable () |
unsigned | directHash () const |
Provides a hash function that uses the object pointer as the hash value. More... | |
virtual UtlBoolean | isEqual (UtlContainable const *) const |
Test this object to another object for equality. More... | |
virtual UtlBoolean | isInstanceOf (const UtlContainableType type) const |
Determine if this object is a derivative of the specified UtlContainableType. More... | |
Static Public Attributes | |
static const UtlContainableType | TYPE = "UtlHashMap" |
Static Public Attributes inherited from UtlContainer | |
static const UtlContainableType | TYPE = "UtlContainer" |
Static Public Attributes inherited from UtlContainable | |
static const UtlContainableType | TYPE = "UtlContainable" |
Protected Member Functions | |
void | resizeIfNeededAndSafe () |
If the Hash is too full, add additional buckets. More... | |
Protected Member Functions inherited from UtlContainer | |
void | addIterator (UtlIterator *newIterator) const |
Add an iterator to the list to be notified of changes to this container. More... | |
void | removeIterator (UtlIterator *existingIterator) const |
Called from iterator destructor to prevent further notices. More... | |
void | invalidateIterators () |
Call the invalidate method on all iterators. More... | |
Protected Attributes | |
size_t | mElements |
number of UtlContainable objects in this UtlHashMap More... | |
size_t | mBucketBits |
number of bits used to index the buckets More... | |
UtlChain * | mpBucket |
an array of 2**n UtlChain elements, each used as a list header. More... | |
Protected Attributes inherited from UtlContainer | |
OsBSem | mContainerLock |
Must be taken when making any change to container state. More... | |
UtlChain | mIteratorList |
Static Protected Attributes | |
static const UtlContainable * | INTERNAL_NULL = &INTERNAL_NULL_OBJECT |
Friends | |
class | UtlHashMapIterator |
Additional Inherited Members | |
Static Public Member Functions inherited from UtlContainer | |
static void | acquireIteratorConnectionLock () |
Lock the linkage between containers and iterators. More... | |
static void | releaseIteratorConnectionLock () |
Unlock the linkage between containers and iterators. More... | |
Static Public Member Functions inherited from UtlContainable | |
static unsigned | stringHash (char const *value) |
Provides a hash function appropriate for null-terminated string values. More... | |
static UtlBoolean | areSameTypes (const UtlContainableType type1, const UtlContainableType type2) |
Are UtlContainable types the same. More... | |
UtlHashMap is a container object that allows you to store keys and values.
Key must be unique (testing for equality using the UtlContainer::isEquals() method).
UtlHashMap | ( | ) |
Default Constructor.
|
virtual |
Destructor.
|
virtual |
Make an off the heap copy of this object.
Make an off the heap, deep copy of this object.
< Class type used for runtime checking
UtlContainable * insertKeyAndValue | ( | UtlContainable * | key, |
UtlContainable * | value | ||
) |
Inserts a key and value pair into the hash map.
If the inserted key is already in the table, this method fails (returns NULL - note that this means if value is NULL, then you can't tell whether there was an error or not). To replace the value for a given key, the old value must be Removed before the new value is inserted.
|
virtual |
Inserts the designated containable object into the list with a NULL value.
If there is an equal key in the UtlHashMap already, the insert will fail.
Implements UtlContainer.
UtlContainable * remove | ( | UtlContainable * | key | ) |
Remove the designated key and its associated value.
|
virtual |
Remove the designated key and its associated value.
Implements UtlContainer.
UtlContainable * removeKeyAndValue | ( | const UtlContainable * | key, |
UtlContainable *& | value | ||
) |
Remove the designated key and its associated value.
The pointer of value is returned as part of the call if successful.
|
virtual |
Removes the designated key and its associated value from the map and frees the key and the value (if not NULL) by calling delete.
pointer | to a UtlContainable for which key->operator==(the actual key) |
Implements UtlContainer.
|
virtual |
Removes all elements from the hash map and deletes each element.
Implements UtlContainer.
|
virtual |
Removes all elements from the hash map without deleting the elements.
Implements UtlContainer.
UtlContainable * findValue | ( | const UtlContainable * | key | ) | const |
Return the value for a given key or NULL if not found.
|
virtual |
Return the designated key if found otherwise NULL.
Implements UtlContainer.
|
virtual |
Return the total number of keys in the hash map.
Implements UtlContainer.
|
virtual |
Return true if the hash map is empty (entries() == 0), otherwise false.
Implements UtlContainer.
|
virtual |
Return true if the hash map includes an entry with the specified key.
Implements UtlContainer.
|
virtual |
Get the ContainableType for the hash bag as a contained object.
Get the ContainableType for the hash map as a contained object.
Reimplemented from UtlContainer.
void copyInto | ( | UtlHashMap & | map | ) | const |
Make a copy of all of the items BY POINTER in (*this) instance into the given map.
It does not clear the given map. IF USING destroyAll call, be sure to call this on only ONE map instance.
OsStatus deepCopyInto | ( | UtlHashMap & | map | ) | const |
This does a deep copy of the object in this UtlHashMap. WARNING: buyer beware, all objects (both keys and values) MUST be derived from UtlCopyableContainable or this method will fail. The clone method is invoked on both keys and values to create copies into the given map. The given map does not need to be empty, but if the key already exists, the copy will fail.
map | - target UtlHashMap to copy key/value pairs to. |
|
inline |
The current number of buckets in the hash.
|
inlineprotected |
If the Hash is too full, add additional buckets.
Assumes that the caller is holding the mContainerLock.
This calls resize to actually do the resize if it is safe.
|
friend |
|
static |
|
staticprotected |
|
protected |
number of UtlContainable objects in this UtlHashMap
|
protected |
number of bits used to index the buckets