/////////////////////////////////////////////////////////////////////////////
// CArray<TYPE, ARG_TYPE>

#ifdef __cplusplus
extern "C" {
#endif

#ifdef __pOS__

extern void *memcpy(unsigned char *s,unsigned char *t,unsigned int n);
extern void *memmove(unsigned char *s,unsigned char *t,unsigned int n);

#endif // __pOS__

#ifdef __cplusplus
}
#endif


#ifndef __AFX_TEMPLATE_H__
#define __AFX_TEMPLATE_H__

#ifdef _DEBUG
	#define ASSERT(a)
	#define ASSERT_VALID(a)
#else
	#define ASSERT(a)
	#define ASSERT_VALID(a)
#endif


#ifdef __cplusplus
extern "C" {
#endif
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
#ifdef __cplusplus
}
#endif

void ConstructElements(void *m_pData, long nNewSize)
{
	// Does nothing
}

void	DestructElements(void *m_pData, long m_nSize)
{
	// Does nothing
}

template<class TYPE, class ARG_TYPE> class aArray
{
public:
// Construction

	aArray()
	{
		m_pData = NULL;
		m_nSize = m_nMaxSize = m_nGrowBy = 0;
	}

// Attributes
	int GetSize(); // const;
	int GetUpperBound() const;
	void SetSize(int nNewSize, int nGrowBy = -1);

// Operations
	// Clean up
	void FreeExtra();
	void RemoveAll();

	// Accessing elements
	TYPE GetAt(int nIndex) const;
	void SetAt(int nIndex, ARG_TYPE newElement);
	TYPE& ElementAt(int nIndex);

	// Direct Access to the element data (may return NULL)
	const TYPE* GetData() const;
	TYPE* GetData();

	// Potentially growing the array
	void SetAtGrow(int nIndex, ARG_TYPE newElement);
	int Add(ARG_TYPE newElement);
	int Append(const class aArray& src);
	void Copy(const class aArray& src);

	// overloaded operator helpers
//	TYPE operator[](int nIndex) const;
	TYPE& operator[](int nIndex);

	// Operations that move elements around
	void InsertAt(int nIndex, ARG_TYPE newElement, int nCount = 1);
	void RemoveAt(int nIndex, int nCount = 1);
	void InsertAt(int nStartIndex, class aArray* pNewArray);

// Implementation
protected:
	TYPE* m_pData;   // the actual array of data
	int m_nSize;     // # of elements (upperBound - 1)
	int m_nMaxSize;  // max allocated
	int m_nGrowBy;   // grow amount
/*
public:

	~aArray();
*/
};


#endif //  __AFX_TEMPLATE_H__