Logo Search packages:      
Sourcecode: virtualbox-ose version File versions

nsTHashtable< EntryType > Class Template Reference

#include <nsTHashtable.h>

Inheritance diagram for nsTHashtable< EntryType >:

nsBaseHashtable< KeyClass, DataType, DataType > nsBaseHashtable< KeyClass, nsAutoPtr< T >, T * > nsBaseHashtable< KeyClass, nsCOMPtr< Interface >, Interface * > nsBaseHashtable< KeyClass, nsRefPtr< RefPtr >, RefPtr * > nsDataHashtable< KeyClass, DataType > nsClassHashtable< KeyClass, T > nsInterfaceHashtable< KeyClass, Interface > nsRefPtrHashtable< KeyClass, RefPtr >

List of all members.

Detailed Description

template<class EntryType>
class nsTHashtable< EntryType >

a base class for templated hashtables.

Clients will rarely need to use this class directly. Check the derived classes first, to see if they will meet your needs.

EntryType the templated entry-type class that is managed by the hashtable. EntryType must extend the following declaration, and must not declare any virtual functions or derive from classes with virtual functions. Any vtable pointer would break the PLDHashTable code.
   class EntryType : public PLDHashEntryHdr
   public: or friend nsTHashtable<EntryType>;
     // KeyType is what we use when Get()ing or Put()ing this entry
     // this should either be a simple datatype (PRUint32, nsISupports*) or
     // a const reference (const nsAString&)
     typedef something KeyType;
     // KeyTypePointer is the pointer-version of KeyType, because pldhash.h
     // requires keys to cast to const void*
     typedef const something* KeyTypePointer;
EntryType(KeyTypePointer aKey);

     // the copy constructor must be defined, even if AllowMemMove() == true
     // or you will cause link errors!
     EntryType(const EntryType& aEnt);

     // the destructor must be defined... or you will cause link errors!

     // return the key of this entry
     const KeyTypePointer GetKeyPointer() const;

     // KeyEquals(): does this entry match this key?
     PRBool KeyEquals(KeyTypePointer aKey) const;

     // KeyToPointer(): Convert KeyType to KeyTypePointer
     static KeyTypePointer KeyToPointer(KeyType aKey);

     // HashKey(): calculate the hash number
     static PLDHashNumber HashKey(KeyTypePointer aKey);

     // ALLOW_MEMMOVE can we move this class with memmove(), or do we have
     // to use the copy constructor?
     enum { ALLOW_MEMMOVE = PR_(TRUE or FALSE) };

See also:



"Benjamin Smedberg <bsmedberg@covad.net>"

Definition at line 109 of file nsTHashtable.h.

Public Types

typedef EntryType::KeyType KeyType
typedef EntryType::KeyTypePointer KeyTypePointer
typedef PLDHashOperator(* PR_CALLBACK )(EntryType *aEntry, void *userArg)

Public Member Functions

void Clear ()
PRUint32 Count () const
PRUint32 EnumerateEntries (Enumerator enumFunc, void *userArg)
EntryType * GetEntry (KeyType aKey) const
PRBool Init (PRUint32 initSize=PL_DHASH_MIN_SIZE)
PRBool IsInitialized () const
 nsTHashtable ()
EntryType * PutEntry (KeyType aKey)
void RawRemoveEntry (EntryType *aEntry)
void RemoveEntry (KeyType aKey)
 ~nsTHashtable ()

Static Protected Member Functions

static void PR_CALLBACK s_ClearEntry (PLDHashTable *table, PLDHashEntryHdr *entry)
static void PR_CALLBACK s_CopyEntry (PLDHashTable *table, const PLDHashEntryHdr *from, PLDHashEntryHdr *to)
static PLDHashOperator PR_CALLBACK s_EnumStub (PLDHashTable *table, PLDHashEntryHdr *entry, PRUint32 number, void *arg)
static const void *PR_CALLBACK s_GetKey (PLDHashTable *table, PLDHashEntryHdr *entry)
static PLDHashNumber PR_CALLBACK s_HashKey (PLDHashTable *table, const void *key)
static PRBool PR_CALLBACK s_InitEntry (PLDHashTable *table, PLDHashEntryHdr *entry, const void *key)
static PRBool PR_CALLBACK s_MatchEntry (PLDHashTable *table, const PLDHashEntryHdr *entry, const void *key)

Protected Attributes

PLDHashTable mTable

Private Member Functions

 nsTHashtable (nsTHashtable< EntryType > &toCopy)
nsTHashtable< EntryType > & operator= (nsTHashtable< EntryType > &toEqual)


struct  s_EnumArgs

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

Generated by  Doxygen 1.6.0   Back to index