Public Types | Public Member Functions | Protected Attributes

nsBaseHashtableMT< KeyClass, DataType, UserDataType > Class Template Reference

This class is a thread-safe version of nsBaseHashtable. More...

#include <nsBaseHashtable.h>

Inheritance diagram for nsBaseHashtableMT< KeyClass, DataType, UserDataType >:
Collaboration diagram for nsBaseHashtableMT< KeyClass, DataType, UserDataType >:

List of all members.

Public Types

typedef nsBaseHashtable
< KeyClass, DataType,
UserDataType >::EntryType 
EntryType
typedef nsBaseHashtable
< KeyClass, DataType,
UserDataType >::KeyType 
KeyType
 KeyType is typedef'ed for ease of use.
typedef nsBaseHashtable
< KeyClass, DataType,
UserDataType >::EnumFunction 
EnumFunction
 function type provided by the application for enumeration.
typedef nsBaseHashtable
< KeyClass, DataType,
UserDataType >
::EnumReadFunction 
EnumReadFunction
 function type provided by the application for enumeration.

Public Member Functions

 nsBaseHashtableMT ()
 ~nsBaseHashtableMT ()
PRBool Init (PRUint32 initSize=16)
 Initialize the object.
PRBool IsInitialized () const
 Check whether the table has been initialized.
PRUint32 Count () const
 Return the number of entries in the table.
PRBool Get (KeyType aKey, UserDataType *pData) const
 retrieve the value for a key.
PRBool Put (KeyType aKey, UserDataType aData)
 put a new value for the associated key
void Remove (KeyType aKey)
 remove the data for the associated key
PRUint32 EnumerateRead (EnumReadFunction enumFunc, void *userArg) const
PRUint32 Enumerate (EnumFunction enumFunc, void *userArg)
void Clear ()
 reset the hashtable, removing all entries

Protected Attributes

PRLockmLock

Detailed Description

template<class KeyClass, class DataType, class UserDataType>
class nsBaseHashtableMT< KeyClass, DataType, UserDataType >

This class is a thread-safe version of nsBaseHashtable.


Member Typedef Documentation

template<class KeyClass, class DataType, class UserDataType>
typedef nsBaseHashtable<KeyClass,DataType,UserDataType>::EntryType nsBaseHashtableMT< KeyClass, DataType, UserDataType >::EntryType
template<class KeyClass, class DataType, class UserDataType>
typedef nsBaseHashtable<KeyClass,DataType,UserDataType>::EnumFunction nsBaseHashtableMT< KeyClass, DataType, UserDataType >::EnumFunction

function type provided by the application for enumeration.

Parameters:
aKey the key being enumerated
aData Reference to data being enumerated, may be altered. e.g. for nsInterfaceHashtable this is an nsCOMPtr reference... userArg passed unchanged from Enumerate
Returns:
bitflag combination of PLDHashOperator::PL_DHASH_REMOVE, PL_DHASH_NEXT , or PL_DHASH_STOP

Reimplemented from nsBaseHashtable< KeyClass, DataType, UserDataType >.

template<class KeyClass, class DataType, class UserDataType>
typedef nsBaseHashtable<KeyClass,DataType,UserDataType>::EnumReadFunction nsBaseHashtableMT< KeyClass, DataType, UserDataType >::EnumReadFunction

function type provided by the application for enumeration.

Parameters:
aKey the key being enumerated
aData data being enumerated userArg passed unchanged from Enumerate
Returns:
either PL_DHASH_NEXT or PL_DHASH_STOP

Reimplemented from nsBaseHashtable< KeyClass, DataType, UserDataType >.

template<class KeyClass, class DataType, class UserDataType>
typedef nsBaseHashtable<KeyClass,DataType,UserDataType>::KeyType nsBaseHashtableMT< KeyClass, DataType, UserDataType >::KeyType

KeyType is typedef'ed for ease of use.

Reimplemented from nsBaseHashtable< KeyClass, DataType, UserDataType >.

Reimplemented in nsClassHashtableMT< KeyClass, T >, and nsRefPtrHashtableMT< KeyClass, RefPtr >.


Constructor & Destructor Documentation

template<class KeyClass, class DataType, class UserDataType>
nsBaseHashtableMT< KeyClass, DataType, UserDataType >::nsBaseHashtableMT (  )  [inline]
template<class KeyClass , class DataType , class UserDataType >
nsBaseHashtableMT< KeyClass, DataType, UserDataType >::~nsBaseHashtableMT (  ) 

Member Function Documentation

template<class KeyClass , class DataType , class UserDataType >
void nsBaseHashtableMT< KeyClass, DataType, UserDataType >::Clear (  ) 

reset the hashtable, removing all entries

Reimplemented from nsBaseHashtable< KeyClass, DataType, UserDataType >.

template<class KeyClass , class DataType , class UserDataType >
PRUint32 nsBaseHashtableMT< KeyClass, DataType, UserDataType >::Count (  )  const

Return the number of entries in the table.

Returns:
number of entries

Reimplemented from nsBaseHashtable< KeyClass, DataType, UserDataType >.

template<class KeyClass , class DataType , class UserDataType >
PRUint32 nsBaseHashtableMT< KeyClass, DataType, UserDataType >::Enumerate ( EnumFunction  enumFunc,
void *  userArg 
)
template<class KeyClass , class DataType , class UserDataType >
PRUint32 nsBaseHashtableMT< KeyClass, DataType, UserDataType >::EnumerateRead ( EnumReadFunction  enumFunc,
void *  userArg 
) const
template<class KeyClass , class DataType , class UserDataType>
PRBool nsBaseHashtableMT< KeyClass, DataType, UserDataType >::Get ( KeyType  aKey,
UserDataType *  pData 
) const

retrieve the value for a key.

Parameters:
aKey the key to retreive
pData data associated with this key will be placed at this pointer. If you only need to check if the key exists, pData may be null.
Returns:
PR_TRUE if the key exists. If key does not exist, pData is not modified.

Reimplemented from nsBaseHashtable< KeyClass, DataType, UserDataType >.

template<class KeyClass , class DataType , class UserDataType >
PRBool nsBaseHashtableMT< KeyClass, DataType, UserDataType >::Init ( PRUint32  initSize = 16  ) 

Initialize the object.

Parameters:
initSize the initial number of buckets in the hashtable, default 16 locking on all class methods
Returns:
PR_TRUE if the object was initialized properly.

Reimplemented from nsBaseHashtable< KeyClass, DataType, UserDataType >.

template<class KeyClass, class DataType, class UserDataType>
PRBool nsBaseHashtableMT< KeyClass, DataType, UserDataType >::IsInitialized (  )  const [inline]

Check whether the table has been initialized.

This function is especially useful for static hashtables.

Returns:
PR_TRUE if the table has been initialized.

Reimplemented from nsBaseHashtable< KeyClass, DataType, UserDataType >.

template<class KeyClass , class DataType , class UserDataType>
PRBool nsBaseHashtableMT< KeyClass, DataType, UserDataType >::Put ( KeyType  aKey,
UserDataType  aData 
)

put a new value for the associated key

Parameters:
aKey the key to put
aData the new data
Returns:
always PR_TRUE, unless memory allocation failed

Reimplemented from nsBaseHashtable< KeyClass, DataType, UserDataType >.

template<class KeyClass , class DataType , class UserDataType >
void nsBaseHashtableMT< KeyClass, DataType, UserDataType >::Remove ( KeyType  aKey  ) 

remove the data for the associated key

Parameters:
aKey the key to remove from the hashtable

Reimplemented from nsBaseHashtable< KeyClass, DataType, UserDataType >.


Member Data Documentation

template<class KeyClass, class DataType, class UserDataType>
PRLock* nsBaseHashtableMT< KeyClass, DataType, UserDataType >::mLock [protected]

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