Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions | Variables
nsHashtable.cpp File Reference
#include <string.h>
#include "prmem.h"
#include "prlog.h"
#include "nsHashtable.h"
#include "nsReadableUtils.h"
#include "nsIObjectInputStream.h"
#include "nsIObjectOutputStream.h"
#include "nsCRT.h"

Go to the source code of this file.

Classes

struct  HTEntry
struct  _HashEnumerateArgs
struct  WriteEntryArgs

Functions

 matchKeyEntry (PLDHashTable *, const PLDHashEntryHdr *entry, const void *key)
 hashKey (PLDHashTable *table, const void *key)
 clearHashEntry (PLDHashTable *table, PLDHashEntryHdr *entry)
 hashEnumerate (PLDHashTable *table, PLDHashEntryHdr *hdr, PRUint32 i, void *arg)
 hashEnumerateShare (PLDHashTable *table, PLDHashEntryHdr *hdr, PRUint32 i, void *arg)
 hashEnumerateRemove (PLDHashTable *, PLDHashEntryHdr *hdr, PRUint32 i, void *arg)
 WriteEntry (nsHashKey *aKey, void *aData, void *aClosure)

Variables

static const PLDHashTableOps hashtableOps

Class Documentation

struct _HashEnumerateArgs

Definition at line 120 of file nsHashtable.cpp.

Class Members
void * arg
nsHashtableEnumFunc fn
struct WriteEntryArgs

Definition at line 411 of file nsHashtable.cpp.

Collaboration diagram for WriteEntryArgs:
Class Members
nsresult mRetVal
nsIObjectOutputStream * mStream
nsHashtableWriteDataFunc mWriteDataFunc

Function Documentation

clearHashEntry ( PLDHashTable table,
PLDHashEntryHdr entry 
)

Definition at line 91 of file nsHashtable.cpp.

{
    HTEntry* hashEntry = NS_STATIC_CAST(HTEntry*, entry);

    // leave it up to the nsHashKey destructor to free the "value"
    delete hashEntry->key;
    hashEntry->key = nsnull;
    hashEntry->value = nsnull;  // probably not necessary, but for
                                // sanity's sake
}
hashEnumerate ( PLDHashTable table,
PLDHashEntryHdr hdr,
PRUint32  i,
void arg 
)

Definition at line 126 of file nsHashtable.cpp.

{
    _HashEnumerateArgs* thunk = (_HashEnumerateArgs*)arg;
    HTEntry* entry = NS_STATIC_CAST(HTEntry*, hdr);
    
    switch (thunk->fn(entry->key, entry->value, thunk->arg)) {
      case kHashEnumerateNext:
        return PL_DHASH_NEXT;
      case kHashEnumerateRemove:
        return PL_DHASH_REMOVE;
    }
    return PL_DHASH_STOP;           
}
hashEnumerateRemove ( PLDHashTable ,
PLDHashEntryHdr hdr,
PRUint32  i,
void arg 
)

Definition at line 324 of file nsHashtable.cpp.

{
    HTEntry* entry = NS_STATIC_CAST(HTEntry*, hdr);
    _HashEnumerateArgs* thunk = (_HashEnumerateArgs*)arg;
    if (thunk) {
        return thunk->fn(entry->key, entry->value, thunk->arg)
            ? PL_DHASH_REMOVE
            : PL_DHASH_STOP;
    }
    return PL_DHASH_REMOVE;
}
hashEnumerateShare ( PLDHashTable table,
PLDHashEntryHdr hdr,
PRUint32  i,
void arg 
)

Definition at line 289 of file nsHashtable.cpp.

{
    nsHashtable *newHashtable = (nsHashtable *)arg;
    HTEntry * entry = NS_STATIC_CAST(HTEntry*, hdr);
    
    newHashtable->Put(entry->key, entry->value);
    return PL_DHASH_NEXT;
}
hashKey ( PLDHashTable table,
const void key 
)

Definition at line 83 of file nsHashtable.cpp.

{
    const nsHashKey* hashKey = NS_STATIC_CAST(const nsHashKey*, key);

    return hashKey->HashCode();
}

Here is the call graph for this function:

matchKeyEntry ( PLDHashTable ,
const PLDHashEntryHdr entry,
const void key 
)

Definition at line 69 of file nsHashtable.cpp.

{
    const HTEntry* hashEntry =
        NS_STATIC_CAST(const HTEntry*, entry);

    if (hashEntry->key == key)
        return PR_TRUE;

    const nsHashKey* otherKey = NS_REINTERPRET_CAST(const nsHashKey*, key);
    return otherKey->Equals(hashEntry->key);
}
WriteEntry ( nsHashKey *  aKey,
void aData,
void aClosure 
)

Definition at line 418 of file nsHashtable.cpp.

{
    WriteEntryArgs* args = (WriteEntryArgs*) aClosure;
    nsIObjectOutputStream* stream = args->mStream;

    nsresult rv = aKey->Write(stream);
    if (NS_SUCCEEDED(rv))
        rv = args->mWriteDataFunc(stream, aData);

    args->mRetVal = rv;
    return PR_TRUE;
}

Variable Documentation