templated hashtable for simple data types This class manages simple data types that do not need construction or destruction. More...
#include <nsBaseHashtable.h>
Classes | |
struct | s_EnumArgs |
struct | s_EnumReadArgs |
used internally during EnumerateRead. More... | |
Public Types | |
typedef KeyClass::KeyType | KeyType |
KeyType is typedef'ed for ease of use. | |
typedef nsBaseHashtableET < KeyClass, DataType > | EntryType |
typedef PLDHashOperator(* | EnumReadFunction )(KeyType aKey, UserDataType aData, void *userArg) |
function type provided by the application for enumeration. | |
typedef PLDHashOperator(* | EnumFunction )(KeyType aKey, DataType &aData, void *userArg) |
function type provided by the application for enumeration. | |
Public Member Functions | |
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 |
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) |
templated hashtable for simple data types This class manages simple data types that do not need construction or destruction.
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* |
typedef nsBaseHashtableET<KeyClass,DataType> nsBaseHashtable< KeyClass, DataType, UserDataType >::EntryType |
typedef PLDHashOperator(* nsBaseHashtable< KeyClass, DataType, UserDataType >::EnumFunction)(KeyType aKey, DataType &aData, void *userArg) |
function type provided by the application for enumeration.
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 |
Reimplemented in nsBaseHashtableMT< KeyClass, DataType, UserDataType >, nsBaseHashtableMT< KeyClass, nsAutoPtr< T >, T * >, nsBaseHashtableMT< KeyClass, nsRefPtr< RefPtr >, RefPtr * >, and nsBaseHashtableMT< KeyClass, DataType, DataType >.
typedef PLDHashOperator(* nsBaseHashtable< KeyClass, DataType, UserDataType >::EnumReadFunction)(KeyType aKey, UserDataType aData, void *userArg) |
function type provided by the application for enumeration.
aKey | the key being enumerated | |
aData | data being enumerated userArg passed unchanged from Enumerate |
Reimplemented in nsBaseHashtableMT< KeyClass, DataType, UserDataType >, nsBaseHashtableMT< KeyClass, nsAutoPtr< T >, T * >, nsBaseHashtableMT< KeyClass, nsRefPtr< RefPtr >, RefPtr * >, and nsBaseHashtableMT< KeyClass, DataType, DataType >.
typedef KeyClass::KeyType nsBaseHashtable< KeyClass, DataType, UserDataType >::KeyType |
KeyType is typedef'ed for ease of use.
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< KeyClass, nsAutoPtr< T >, T * >, nsBaseHashtableMT< KeyClass, nsRefPtr< RefPtr >, RefPtr * >, nsBaseHashtableMT< KeyClass, DataType, DataType >, nsClassHashtable< nsISupportsHashKey, nsInsertionPointList >, nsRefPtrHashtable< nsStringHashKey, gfxMixedFontFamily >, nsRefPtrHashtable< nsISupportsHashKey, nsXBLBinding >, and nsRefPtrHashtable< nsVoidPtrHashKey, nsImageLoader >.
void nsBaseHashtable< KeyClass, DataType, UserDataType >::Clear | ( | ) | [inline] |
reset the hashtable, removing all entries
Reimplemented from nsTHashtable< nsBaseHashtableET< KeyClass, DataType > >.
Reimplemented in nsBaseHashtableMT< KeyClass, DataType, UserDataType >, nsBaseHashtableMT< KeyClass, nsAutoPtr< T >, T * >, nsBaseHashtableMT< KeyClass, nsRefPtr< RefPtr >, RefPtr * >, and nsBaseHashtableMT< KeyClass, DataType, DataType >.
PRUint32 nsBaseHashtable< KeyClass, DataType, UserDataType >::Count | ( | ) | const [inline] |
Return the number of entries in the table.
Reimplemented from nsTHashtable< nsBaseHashtableET< KeyClass, DataType > >.
Reimplemented in nsBaseHashtableMT< KeyClass, DataType, UserDataType >, nsBaseHashtableMT< KeyClass, nsAutoPtr< T >, T * >, nsBaseHashtableMT< KeyClass, nsRefPtr< RefPtr >, RefPtr * >, and nsBaseHashtableMT< KeyClass, DataType, DataType >.
PRUint32 nsBaseHashtable< KeyClass, DataType, UserDataType >::Enumerate | ( | EnumFunction | enumFunc, | |
void * | userArg | |||
) | [inline] |
enumerate entries in the hashtable, allowing changes.
This functions write-locks the hashtable.
enumFunc | enumeration callback | |
userArg | passed unchanged to the EnumFunction |
PRUint32 nsBaseHashtable< KeyClass, DataType, UserDataType >::EnumerateRead | ( | EnumReadFunction | enumFunc, | |
void * | userArg | |||
) | const [inline] |
enumerate entries in the hashtable, without allowing changes
enumFunc | enumeration callback | |
userArg | passed unchanged to the EnumReadFunction |
PRBool nsBaseHashtable< KeyClass, DataType, UserDataType >::Get | ( | KeyType | aKey, | |
UserDataType * | pData | |||
) | const [inline] |
retrieve the value for a key.
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. |
Reimplemented in nsBaseHashtableMT< KeyClass, DataType, UserDataType >, and nsBaseHashtableMT< KeyClass, DataType, DataType >.
PRBool nsBaseHashtable< KeyClass, DataType, UserDataType >::Init | ( | PRUint32 | initSize = 16 |
) | [inline] |
Initialize the object.
initSize | the initial number of buckets in the hashtable, default 16 locking on all class methods |
Reimplemented from nsTHashtable< nsBaseHashtableET< KeyClass, DataType > >.
Reimplemented in nsBaseHashtableMT< KeyClass, DataType, UserDataType >, nsBaseHashtableMT< KeyClass, nsAutoPtr< T >, T * >, nsBaseHashtableMT< KeyClass, nsRefPtr< RefPtr >, RefPtr * >, and nsBaseHashtableMT< KeyClass, DataType, DataType >.
PRBool nsBaseHashtable< KeyClass, DataType, UserDataType >::IsInitialized | ( | ) | const [inline] |
Check whether the table has been initialized.
This function is especially useful for static hashtables.
Reimplemented from nsTHashtable< nsBaseHashtableET< KeyClass, DataType > >.
Reimplemented in nsBaseHashtableMT< KeyClass, DataType, UserDataType >, nsBaseHashtableMT< KeyClass, nsAutoPtr< T >, T * >, nsBaseHashtableMT< KeyClass, nsRefPtr< RefPtr >, RefPtr * >, and nsBaseHashtableMT< KeyClass, DataType, DataType >.
PRBool nsBaseHashtable< KeyClass, DataType, UserDataType >::Put | ( | KeyType | aKey, | |
UserDataType | aData | |||
) | [inline] |
put a new value for the associated key
aKey | the key to put | |
aData | the new data |
Reimplemented in nsBaseHashtableMT< KeyClass, DataType, UserDataType >, and nsBaseHashtableMT< KeyClass, DataType, DataType >.
void nsBaseHashtable< KeyClass, DataType, UserDataType >::Remove | ( | KeyType | aKey | ) | [inline] |
remove the data for the associated key
aKey | the key to remove from the hashtable |
Reimplemented in nsBaseHashtableMT< KeyClass, DataType, UserDataType >, nsBaseHashtableMT< KeyClass, nsAutoPtr< T >, T * >, nsBaseHashtableMT< KeyClass, nsRefPtr< RefPtr >, RefPtr * >, and nsBaseHashtableMT< KeyClass, DataType, DataType >.
PLDHashOperator nsBaseHashtable< KeyClass, DataType, UserDataType >::s_EnumReadStub | ( | PLDHashTable * | table, | |
PLDHashEntryHdr * | hdr, | |||
PRUint32 | number, | |||
void * | arg | |||
) | [static, protected] |
PLDHashOperator nsBaseHashtable< KeyClass, DataType, UserDataType >::s_EnumStub | ( | PLDHashTable * | table, | |
PLDHashEntryHdr * | hdr, | |||
PRUint32 | number, | |||
void * | arg | |||
) | [static, protected] |
Reimplemented from nsTHashtable< nsBaseHashtableET< KeyClass, DataType > >.