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

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


class V2_CLASS_API CBoolArray
{
private:
	bool *m_pData;
	int m_iSize;
	int m_iBufferSize;

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

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

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

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

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

	bool &operator[](const int p_iIndex) const;
	CBoolArray &operator=(const CBoolArray &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	/* __BOOL_ARRAY_H__ */
