Symbian
Symbian OS Library

SYMBIAN OS V9.3

[Index] [Spacer] [Previous] [Next]



Location: e32hashtab.h

This item is not part of the S60 3rd Edition SDK for Symbian OS, Feature Pack 2.

Class RPtrHashMap

class RPtrHashMap : public RHashTableBase;

Description

A templated class which implements an associative array with key type K and value type V, using a probe-sequence hash table. Neither the key nor value objects are copied into the table when they are added - only pointers are stored.

Derivation

Members

Defined in RPtrHashMap:
Close(), Count(), Find(), Find(), FindL(), FindL(), Insert(), InsertL(), RPtrHashMap(), RPtrHashMap(), Remove(), Reserve(), ReserveL(), ResetAndDestroy(), TIter


Construction and destruction


RPtrHashMap()

inline RPtrHashMap(const THashFunction32< K > &aHash, const TIdentityRelation< K > &aIdentity);

Description

Construct an associative array of key-value pairs of type (K,V) using a specified hash function and identity relation. The array initially contains no key-value pairs.

Parameters

const THashFunction32< K > &aHash

The hash function used to hash the key objects of type K.

const TIdentityRelation< K > &aIdentity

The identity relation used to determine if two key objects of type K should be considered identical.


RPtrHashMap()

inline RPtrHashMap();

Description

Construct an associative array of key-value pairs of type (K,V) using a default hash function and identity relation. The array initially contains no key-value pairs.

[Top]


Member functions


Close()

inline void Close();

Description

Free all memory used by this array. Returns the array to the same state it had following construction.


Find()

inline const V *Find(const K &aKey) const;

Description

Look up a specified key in the associative array and return a pointer to the corresponding value.

Parameters

const K &aKey

The key object of type K to look up.

Return value

const V *

A pointer to corresponding value object if the specified key object was found. The value object may not be modified via this pointer. NULL if the specified key object was not found.


FindL()

inline const V &FindL(const K &aKey) const;

Description

Look up a specified key in the associative array and return a pointer to the corresponding value.

Parameters

const K &aKey

The key object of type K to look up.

Return value

const V &

A reference to corresponding value object if the specified key object was found. The value object may not be modified via this reference.

Leave codes

KErrNotFound

if the specified key object was not found.


Find()

inline V *Find(const K &aKey);

Description

Look up a specified key in the associative array and return a pointer to the corresponding value.

Parameters

const K &aKey

The key object of type K to look up.

Return value

V *

A pointer to corresponding value object if the specified key object was found. The value object may be modified via this pointer. NULL if the specified key object was not found.


FindL()

inline V &FindL(const K &aKey);

Description

Look up a specified key in the associative array and return a pointer to the corresponding value.

Parameters

const K &aKey

The key object of type K to look up.

Return value

V &

A reference to corresponding value object if the specified key object was found. The value object may be modified via this reference.

Leave codes

KErrNotFound

if the specified key object was not found.


Insert()

inline TInt Insert(const K *aKey, const V *aValue);

Description

Insert a key-value pair into the array.

If the specified key object is not found in the array, a pointer to the key object along with a pointer to the value object are added to the array and KErrNone is returned. If the specified key object is found in the array, the existing pointers to both the key and value objects are replaced by the provided pointers and KErrNone is returned. In both cases only pointers are stored in the array - the objects themselves are not copied.

Parameters

const K *aKey

A pointer to the key object of type K to add to the array.

const V *aValue

A pointer to the value object of type V to associate with aKey.

Return value

TInt

KErrNone if the key-value pair was added successfully. KErrNoMemory if memory could not be allocated to store the pointers aKey and aValue.


InsertL()

inline void InsertL(const K *aKey, const V *aValue);

Description

Insert a key-value pair into the array.

If the specified key object is not found in the array, a pointer to the key object along with a pointer to the value object are added to the array and KErrNone is returned. If the specified key object is found in the array, the existing pointers to both the key and value objects are replaced by the provided pointers and KErrNone is returned. In both cases only pointers are stored in the array - the objects themselves are not copied.

Parameters

const K *aKey

A pointer to the key object of type K to add to the array.

const V *aValue

A pointer to the value object of type V to associate with aKey.

Leave codes

KErrNoMemory

if memory could not be allocated to store the pointers aKey and aValue.


Remove()

inline TInt Remove(const K *aKey);

Description

Remove a key-value pair from the array.

Parameters

const K *aKey

A pointer to the key to be removed.

Return value

TInt

KErrNone if the pointers to the key object and corresponding value object were removed successfully. KErrNotFound if the key object was not present in the array.


Count()

inline TInt Count() const;

Description

Query the number of key-value pairs in the array.

Return value

TInt

The number of key-value pairs currently in the array.


Reserve()

inline TInt Reserve(TInt aCount);

Description

Expand the array to accommodate a specified number of key-value pairs. If the set already has enough space for the specified number of elements, no action is taken. Any elements already in the set are retained.

Parameters

TInt aCount

The number of key-value pairs for which space should be allocated.

Return value

TInt

KErrNone if the operation completed successfully. KErrNoMemory if sufficient memory could not be allocated.


ReserveL()

inline void ReserveL(TInt aCount);

Description

Expand the array to accommodate a specified number of key-value pairs. If the set already has enough space for the specified number of elements, no action is taken. Any elements already in the set are retained.

Parameters

TInt aCount

The number of key-value pairs for which space should be allocated.

Leave codes

KErrNoMemory

if sufficient memory could not be allocated.


ResetAndDestroy()

void ResetAndDestroy();

Description

Deletes all the key objects of type K and corresponding value objects of type V to which pointers are stored in this array. Then frees all the memory used by the array and returns the array to the same state as immediately following construction.

[Top]


Member type definitions


Typedef TIter

typedef TPtrHashMapIter<K,V> RPtrHashMap< K, V >::TIter;

Description

A class which allows iteration over the elements of a RPtrHashMap<K,V> class.

The array being iterated over may not be modified while an iteration is in progress or the iteration operations may malfunction or panic.