nsBaseHashtable< KeyClass, DataType, UserDataType > Class Template Reference

#include <nsBaseHashtable.h>

Inheritance diagram for nsBaseHashtable< KeyClass, DataType, UserDataType >:

Inheritance graph
[legend]
Collaboration diagram for nsBaseHashtable< KeyClass, DataType, UserDataType >:

Collaboration graph
[legend]

List of all members.


Detailed Description

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

Parameters:
KeyClass a wrapper-class for the hashtable key, see nsHashKeys.h for a complete specification.
DataType the datatype stored in the hashtable, for example, PRUint32 or nsCOMPtr. If UserDataType is not the same, DataType must implicitly cast to UserDataType
UserDataType the user sees, for example PRUint32 or nsISupports*

Public Types

typedef KeyClass::KeyType KeyType
 KeyType is typedef'ed for ease of use.
typedef nsBaseHashtableET
< KeyClass, DataType > 
EntryType
typedef PLDHashOperator(* PR_CALLBACK )(KeyType aKey, UserDataType aData, void *userArg)
 function type provided by the application for enumeration.
typedef PLDHashOperator(* PR_CALLBACK )(KeyType aKey, DataType &aData, void *userArg)
 function type provided by the application for enumeration.

Public Member Functions

PRBool Init (PRUint32 initSize=PL_DHASH_MIN_SIZE)
 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
 enumerate entries in the hashtable, without allowing changes
PRUint32 Enumerate (EnumFunction enumFunc, void *userArg)
 enumerate entries in the hashtable, allowing changes.
void Clear ()
 reset the hashtable, removing all entries

Static Protected Member Functions

static PLDHashOperator s_EnumReadStub (PLDHashTable *table, PLDHashEntryHdr *hdr, PRUint32 number, void *arg)
static PLDHashOperator s_EnumStub (PLDHashTable *table, PLDHashEntryHdr *hdr, PRUint32 number, void *arg)

Classes

struct  s_EnumArgs
struct  s_EnumReadArgs
 used internally during EnumerateRead. More...

Member Typedef Documentation

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

Reimplemented from nsTHashtable< nsBaseHashtableET< KeyClass, DataType > >.

Reimplemented in nsBaseHashtableMT< KeyClass, DataType, UserDataType >, nsClassHashtable< KeyClass, T >, nsClassHashtableMT< KeyClass, T >, nsRefPtrHashtable< KeyClass, RefPtr >, nsRefPtrHashtableMT< KeyClass, RefPtr >, nsBaseHashtableMT< struct KeyClass, DataType, DataType >, nsBaseHashtableMT< struct KeyClass, nsAutoPtr< T >, T * >, nsBaseHashtableMT< struct KeyClass, nsRefPtr< RefPtr >, RefPtr * >, nsClassHashtable< nsUint32HashKey, nsMAPISession >, nsClassHashtable< nsStringHashKey, nsCString >, nsClassHashtable< nsVoidPtrHashKey, DConnectInstance >, nsClassHashtable< nsCStringHashKey, EmbedPasswordMgr::SignonHashEntry >, nsClassHashtable< nsISupportsHashKey, nsTArray >, nsClassHashtable< FunctionKey, ProfilerFunction >, nsClassHashtable< nsISupportsHashKey, nsXFormsMDGNode >, nsClassHashtable< nsCStringHashKey, nsPresState >, nsClassHashtable< nsISupportsHashKey, nsCOMArray< nsXULTemplateResultRDF > >, nsClassHashtable< nsUint32HashKey, gfxPangoFontWrapper >, nsClassHashtable< nsVoidPtrHashKey, nsOfflineCacheUpdateService::PendingUpdate >, nsClassHashtable< nsISupportsHashKey, nsString >, nsClassHashtable< nsCharPtrHashKey, nsCOMArray< nsIObserver > >, nsClassHashtable< nsISupportsHashKey, nsXFormsNodeState >, nsClassHashtable< nsHashableHashKey, mozJSComponentLoader::ModuleEntry >, nsClassHashtable< nsStringHashKey, nsCounterList >, nsClassHashtable< nsUint32HashKey, nsCOMArray< nsXULTemplateResultRDF > >, nsClassHashtable< nsDepCharHashKey, CategoryNode >, nsClassHashtable< nsCharPtrHashKey, ProfilerFile >, nsClassHashtable< nsStringHashKey, nsSVGFilterInstance::ImageEntry >, nsClassHashtable< nsStringHashKey, nsRadioGroupStruct >, nsRefPtrHashtable< nsStringHashKey, MacOSFamilyEntry >, nsRefPtrHashtable< nsURIHashKey, nsXULPrototypeDocument >, nsRefPtrHashtable< nsCStringHashKey, nsDownload >, nsRefPtrHashtable< nsISupportsHashKey, nsXFormsControlListItem >, nsRefPtrHashtable< nsISupportsHashKey, nsXMLBindingSet >, nsRefPtrHashtable< nsVoidPtrHashKey, nsThread >, nsRefPtrHashtable< nsISupportsHashKey, RDFBindingSet >, nsRefPtrHashtable< nsISupportsHashKey, gfxASurface >, nsRefPtrHashtable< nsISupportsHashKey, nsXBLBinding >, and nsRefPtrHashtable< nsIDHashKey, ipcTargetData >.

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

template<class KeyClass, class DataType, class UserDataType>
typedef PLDHashOperator(* nsBaseHashtable< KeyClass, DataType, UserDataType >::PR_CALLBACK)(KeyType aKey, UserDataType aData, void *userArg)

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 nsTHashtable< nsBaseHashtableET< KeyClass, DataType > >.

template<class KeyClass, class DataType, class UserDataType>
typedef PLDHashOperator(* nsBaseHashtable< KeyClass, DataType, UserDataType >::PR_CALLBACK)(KeyType aKey, DataType &aData, void *userArg)

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 nsTHashtable< nsBaseHashtableET< KeyClass, DataType > >.


Member Function Documentation

template<class KeyClass, class DataType, class UserDataType>
PRBool nsBaseHashtable< KeyClass, DataType, UserDataType >::Init ( PRUint32  initSize = PL_DHASH_MIN_SIZE  )  [inline]

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 nsTHashtable< nsBaseHashtableET< KeyClass, DataType > >.

Reimplemented in nsBaseHashtableMT< KeyClass, DataType, UserDataType >, nsBaseHashtableMT< struct KeyClass, DataType, DataType >, nsBaseHashtableMT< struct KeyClass, nsAutoPtr< T >, T * >, and nsBaseHashtableMT< struct KeyClass, nsRefPtr< RefPtr >, RefPtr * >.

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

template<class KeyClass, class DataType, class UserDataType>
PRUint32 nsBaseHashtable< KeyClass, DataType, UserDataType >::Count (  )  const [inline]

template<class KeyClass, class DataType, class UserDataType>
PRBool nsBaseHashtable< KeyClass, DataType, UserDataType >::Get ( KeyType  aKey,
UserDataType *  pData 
) const [inline]

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 in nsBaseHashtableMT< KeyClass, DataType, UserDataType >.

template<class KeyClass, class DataType, class UserDataType>
PRBool nsBaseHashtable< KeyClass, DataType, UserDataType >::Put ( KeyType  aKey,
UserDataType  aData 
) [inline]

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

Reimplemented in nsBaseHashtableMT< KeyClass, DataType, UserDataType >.

template<class KeyClass, class DataType, class UserDataType>
void nsBaseHashtable< KeyClass, DataType, UserDataType >::Remove ( KeyType  aKey  )  [inline]

template<class KeyClass, class DataType, class UserDataType>
PRUint32 nsBaseHashtable< KeyClass, DataType, UserDataType >::EnumerateRead ( EnumReadFunction  enumFunc,
void *  userArg 
) const [inline]

Parameters:
enumFunc enumeration callback
userArg passed unchanged to the EnumReadFunction

template<class KeyClass, class DataType, class UserDataType>
PRUint32 nsBaseHashtable< KeyClass, DataType, UserDataType >::Enumerate ( EnumFunction  enumFunc,
void *  userArg 
) [inline]

This functions write-locks the hashtable.

Parameters:
enumFunc enumeration callback
userArg passed unchanged to the EnumFunction

template<class KeyClass, class DataType, class UserDataType>
void nsBaseHashtable< KeyClass, DataType, UserDataType >::Clear (  )  [inline]

template<class KeyClass, class DataType, class UserDataType>
PLDHashOperator nsBaseHashtable< KeyClass, DataType, UserDataType >::s_EnumReadStub ( PLDHashTable table,
PLDHashEntryHdr hdr,
PRUint32  number,
void *  arg 
) [inline, static, protected]

template<class KeyClass, class DataType, class UserDataType>
PLDHashOperator nsBaseHashtable< KeyClass, DataType, UserDataType >::s_EnumStub ( PLDHashTable table,
PLDHashEntryHdr hdr,
PRUint32  number,
void *  arg 
) [inline, static, protected]


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

Generated Mozilla by doxygen 1.5.6