Back to index

lightning-sunbird  0.9+nobinonly
Classes | Public Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends
nsClusterKeySet Class Reference

A collection of nsClusterKey objects. More...

#include <nsClusterKeySet.h>

Collaboration diagram for nsClusterKeySet:
Collaboration graph
[legend]

List of all members.

Classes

class  ConstIterator
class  Entry

Public Member Functions

 nsClusterKeySet ()
 ~nsClusterKeySet ()
ConstIterator First () const
ConstIterator Last () const
PRBool Contains (const nsClusterKey &aKey)
nsresult Add (const nsClusterKey &aKey)

Static Protected Member Functions

static void *PR_CALLBACK AllocTable (void *aPool, PRSize aSize)
static void PR_CALLBACK FreeTable (void *aPool, void *aItem)
static PLHashEntry *PR_CALLBACK AllocEntry (void *aPool, const void *aKey)
static void PR_CALLBACK FreeEntry (void *aPool, PLHashEntry *aEntry, PRUintn aFlag)

Protected Attributes

PLHashTablemTable
Entry mHead
nsFixedSizeAllocator mPool

Static Protected Attributes

static PLHashAllocOps gAllocOps

Friends

class ConstIterator

Detailed Description

A collection of nsClusterKey objects.

Definition at line 48 of file nsClusterKeySet.h.


Constructor & Destructor Documentation

Definition at line 45 of file nsClusterKeySet.cpp.

    : mTable(nsnull)
{
    mHead.mPrev = mHead.mNext = &mHead;

    static const size_t kBucketSizes[] = { sizeof(Entry) };
    static const PRInt32 kNumBuckets = sizeof(kBucketSizes) / sizeof(size_t);
    static const PRInt32 kInitialEntries = 8;

    // Per news://news.mozilla.org/39BEC105.5090206%40netscape.com
    static const PRInt32 kInitialPoolSize = 256;

    mPool.Init("nsClusterKeySet", kBucketSizes, kNumBuckets, kInitialPoolSize);

    mTable = PL_NewHashTable(kInitialEntries,
                             nsClusterKey::HashClusterKey,
                             nsClusterKey::CompareClusterKeys,
                             PL_CompareValues, &gAllocOps, &mPool);

    MOZ_COUNT_CTOR(nsClusterKeySet);
}

Here is the call graph for this function:

Definition at line 68 of file nsClusterKeySet.cpp.

Here is the call graph for this function:


Member Function Documentation

Definition at line 81 of file nsClusterKeySet.cpp.

{
    PLHashNumber hash = aKey.Hash();
    PLHashEntry** hep = PL_HashTableRawLookup(mTable, hash, &aKey);

    if (hep && *hep)
        return NS_OK; // already had it.

    PLHashEntry* he = PL_HashTableRawAdd(mTable, hep, hash, &aKey, nsnull);
    if (! he)
        return NS_ERROR_OUT_OF_MEMORY;

    Entry* entry = NS_REINTERPRET_CAST(Entry*, he);

    // XXX yes, I am evil. Fixup the key in the hashentry to point to
    // the value it contains, rather than the one on the stack.
    entry->mHashEntry.key = &entry->mKey;

    // thread
    mHead.mPrev->mNext = entry;
    entry->mPrev = mHead.mPrev;
    entry->mNext = &mHead;
    mHead.mPrev = entry;
    
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PLHashEntry* PR_CALLBACK nsClusterKeySet::AllocEntry ( void aPool,
const void aKey 
) [inline, static, protected]

Definition at line 145 of file nsClusterKeySet.h.

                                                                              {
        nsFixedSizeAllocator* pool = NS_STATIC_CAST(nsFixedSizeAllocator*, aPool);
        const nsClusterKey* key = NS_STATIC_CAST(const nsClusterKey*, aKey);
        Entry* entry = Entry::Create(*pool, *key);
        return NS_REINTERPRET_CAST(PLHashEntry*, entry); }

Here is the call graph for this function:

static void* PR_CALLBACK nsClusterKeySet::AllocTable ( void aPool,
PRSize  aSize 
) [inline, static, protected]

Definition at line 139 of file nsClusterKeySet.h.

                                                                   {
        return new char[aSize]; }

Definition at line 75 of file nsClusterKeySet.cpp.

{
    return nsnull != PL_HashTableLookup(mTable, &aKey);
}

Here is the call graph for this function:

Definition at line 130 of file nsClusterKeySet.h.

{ return ConstIterator(mHead.mNext); }

Here is the caller graph for this function:

static void PR_CALLBACK nsClusterKeySet::FreeEntry ( void aPool,
PLHashEntry aEntry,
PRUintn  aFlag 
) [inline, static, protected]

Definition at line 151 of file nsClusterKeySet.h.

                                                                                       {
        nsFixedSizeAllocator* pool = NS_STATIC_CAST(nsFixedSizeAllocator*, aPool);
        if (aFlag == HT_FREE_ENTRY)
            Entry::Destroy(*pool, NS_REINTERPRET_CAST(Entry*, aEntry)); }

Here is the call graph for this function:

static void PR_CALLBACK nsClusterKeySet::FreeTable ( void aPool,
void aItem 
) [inline, static, protected]

Definition at line 142 of file nsClusterKeySet.h.

                                                                {
        delete[] NS_STATIC_CAST(char*, aItem); }

Definition at line 131 of file nsClusterKeySet.h.

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class ConstIterator [friend]

Definition at line 50 of file nsClusterKeySet.h.


Member Data Documentation

Initial value:

Definition at line 137 of file nsClusterKeySet.h.

Definition at line 86 of file nsClusterKeySet.h.

nsFixedSizeAllocator nsClusterKeySet::mPool [protected]

Definition at line 88 of file nsClusterKeySet.h.

Definition at line 85 of file nsClusterKeySet.h.


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