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

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


class V2_CLASS_API CDblArray
{
private:
	double *m_pData;
	int m_iSize;
	int m_iBufferSize;

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

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

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

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

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

	double &operator[](const int p_iIndex) const;
	CDblArray &operator=(const CDblArray &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	/* __DBL_ARRAY_H__ */
