/*******************************************************************************
 *
 *	Copyright (C) 2008 ITS Co., Ltd. All rights reserved.
 *
 *	SubSystem Name : 
 *	Initial Author : hsahn
 *	Description: array template for int, double, bool
 *			XXX Don't edit this file directly (modify tmpl_array.h)XXX
 ******************************************************************************/

#ifndef __INT_ARRAY_H__
#define __INT_ARRAY_H__

#include "cstring.h"
#include "exception.h"


class V2_CLASS_API CIntArray
{
private:
	int *m_pData;
	int m_iSize;
	int m_iBufferSize;

public:
	CIntArray();
	CIntArray(int p_iSize, int p_DefVal);
	CIntArray(CIntArray &p_Obj);
	~CIntArray();
public:
	void Clear();	// data clear but don't delete data buffer

	int Add(const int p_NewData);
	int GetSize() const { return m_iSize; }
	void Reset(const int p_iSize, const int p_DefVal);

	int GetAt(const int p_iIndex) const;
	void SetAt(const int p_iIndex, const int p_NewData);
	int GetAtLast(void) const;
	int InsertAt(const int p_iIndex, const int p_NewData);
	int RemoveAt(const int p_iIndex);

	bool IsEmpty(void) const { return (m_iSize == 0) ? true : false; }
	bool IsIn(const int p_Data) const;
	int Find(const int p_Data) const;
	void Sort(void);

	void RemoveLast(void);
	void RemoveAll(void);	// delete data buffer

	int &operator[](const int p_iIndex) const;
	CIntArray &operator=(const CIntArray &p_Obj);

	void SetNull(void) { RemoveAll(); }
	bool IsValid(void) const { return (m_iSize > 0) ? true : false; }
	CString Repr(const char *p_szSep=", ", const bool p_bInfo=false) const;

private:
	void GrowBuffer(int p_iGrowSize=0);
};


#endif	/* __INT_ARRAY_H__ */
