/*******************************************************************************
 *
 *	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 __DATE_ARRAY_H__
#define __DATE_ARRAY_H__

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

class V2_CLASS_API CDateArray
{
private:
	CDate *m_pData;
	int m_iSize;
	int m_iBufferSize;

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

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

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

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

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

	CDate &operator[](const int p_iIndex) const;
	CDateArray &operator=(const CDateArray &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	/* __DATE_ARRAY_H__ */
