Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Attributes
nsSimpleArray< Entry > Class Template Reference

#include <nsPluginHostCtrl.h>

Inheritance diagram for nsSimpleArray< Entry >:
Inheritance graph
[legend]
Collaboration diagram for nsSimpleArray< Entry >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsSimpleArray (unsigned long nExpandArrayBy=10)
virtual ~nsSimpleArray ()
Entry ElementAt (unsigned long aIndex) const
Entry operator[] (unsigned long aIndex) const
void AppendElement (Entry entry)
void RemoveElementAt (unsigned long nIndex)
void RemoveElement (Entry entry)
void Empty ()
BOOL IsEmpty () const
unsigned long Count () const

Private Attributes

Entrym_pData
unsigned long m_nSize
unsigned long m_nMaxSize
unsigned long m_nExpandArrayBy

Detailed Description

template<class Entry>
class nsSimpleArray< Entry >

Definition at line 51 of file nsPluginHostCtrl.h.


Constructor & Destructor Documentation

template<class Entry>
nsSimpleArray< Entry >::nsSimpleArray ( unsigned long  nExpandArrayBy = 10) [inline]

Definition at line 58 of file nsPluginHostCtrl.h.

                                                     :
      m_pData(NULL),
      m_nSize(0),
      m_nMaxSize(0),
      m_nExpandArrayBy(nExpandArrayBy)
    {
    }
template<class Entry>
virtual nsSimpleArray< Entry >::~nsSimpleArray ( ) [inline, virtual]

Definition at line 66 of file nsPluginHostCtrl.h.

    {
        Empty();
    }

Member Function Documentation

template<class Entry>
void nsSimpleArray< Entry >::AppendElement ( Entry  entry) [inline]

Definition at line 82 of file nsPluginHostCtrl.h.

    {
        if (!m_pData)
        {
            m_nMaxSize = m_nExpandArrayBy;
            m_pData = (Entry *) malloc(sizeof(Entry) * m_nMaxSize);
        }
        else if (m_nSize == m_nMaxSize)
        {
            m_nMaxSize += m_nExpandArrayBy;
            m_pData = (Entry *) realloc(m_pData, sizeof(Entry) * m_nMaxSize);
        }
        ATLASSERT(m_pData);
        if (m_pData)
        {
            m_pData[m_nSize++] = entry;
        }
    }
template<class Entry>
unsigned long nsSimpleArray< Entry >::Count ( ) const [inline]

Definition at line 144 of file nsPluginHostCtrl.h.

{ return m_nSize; }
template<class Entry>
Entry nsSimpleArray< Entry >::ElementAt ( unsigned long  aIndex) const [inline]

Definition at line 71 of file nsPluginHostCtrl.h.

    {
        ATLASSERT(aIndex < m_nSize);
        return m_pData[aIndex];
    }

Here is the caller graph for this function:

template<class Entry>
void nsSimpleArray< Entry >::Empty ( ) [inline]

Definition at line 134 of file nsPluginHostCtrl.h.

    {
        if (m_pData)
        {
            free(m_pData);
            m_pData = NULL;
            m_nSize = m_nMaxSize = 0;
        }
    }

Here is the caller graph for this function:

template<class Entry>
BOOL nsSimpleArray< Entry >::IsEmpty ( ) const [inline]

Definition at line 143 of file nsPluginHostCtrl.h.

{ return m_nSize == 0 ? TRUE : FALSE; }
template<class Entry>
Entry nsSimpleArray< Entry >::operator[] ( unsigned long  aIndex) const [inline]

Definition at line 77 of file nsPluginHostCtrl.h.

    {
        return ElementAt(aIndex);
    }
template<class Entry>
void nsSimpleArray< Entry >::RemoveElement ( Entry  entry) [inline]

Definition at line 115 of file nsPluginHostCtrl.h.

    {
        unsigned long i = 0;
        while (i < m_nSize)
        {
            if (m_pData[i] == entry)
            {
                m_nSize--;
                if (m_nSize > 0)
                {
                    m_pData[i] = m_pData[m_nSize - 1];
                    m_nSize--;
                }
                continue;
            }
            i++;
        }
    }
template<class Entry>
void nsSimpleArray< Entry >::RemoveElementAt ( unsigned long  nIndex) [inline]

Definition at line 101 of file nsPluginHostCtrl.h.

    {
        ATLASSERT(aIndex < m_nSize);
        if (nIndex < m_nSize)
        {
            m_nSize--;
            if (m_nSize > 0)
            {
                m_pData[nIndex] = m_pData[m_nSize - 1];
                m_nSize--;
            }
        }
    }

Member Data Documentation

template<class Entry>
unsigned long nsSimpleArray< Entry >::m_nExpandArrayBy [private]

Definition at line 56 of file nsPluginHostCtrl.h.

template<class Entry>
unsigned long nsSimpleArray< Entry >::m_nMaxSize [private]

Definition at line 55 of file nsPluginHostCtrl.h.

template<class Entry>
unsigned long nsSimpleArray< Entry >::m_nSize [private]

Definition at line 54 of file nsPluginHostCtrl.h.

template<class Entry>
Entry* nsSimpleArray< Entry >::m_pData [private]

Definition at line 53 of file nsPluginHostCtrl.h.


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