CObList( int nBlockSize = 10 );
Parameters
nBlockSize
The memory-allocation granularity for extending the list.
Remarks
Constructs an empty CObject pointer list. As the list grows, memory is allocated in units of nBlockSize entries. If a memory allocation fails, a CMemoryException is thrown.
Example
Below is a listing of the CObject-derived class CAge
used in all the collection examples:
// Simple CObject-derived class for CObList examples
class CAge : public CObject
{
DECLARE_SERIAL( CAge )
private:
int m_years;
public:
CAge() { m_years = 0; }
CAge( int age ) { m_years = age; }
CAge( const CAge& a ) { m_years = a.m_years; } // Copy constructor
void Serialize( CArchive& ar);
void AssertValid() const;
const CAge& operator=( const CAge& a )
{
m_years = a.m_years; return *this;
}
BOOL operator==(CAge a)
{
return m_years == a.m_years;
}
#ifdef _DEBUG
void Dump( CDumpContext& dc ) const
{
CObject::Dump( dc );
dc << m_years;
}
#endif
};
Below is an example of CObList constructor usage:
CObList list( 20 ); // List on the stack with blocksize = 20.
CObList* plist = new CObList; // List on the heap with default
// blocksize.