Compare commits
64 Commits
Author | SHA1 | Date | |
---|---|---|---|
/* User with id == 0 is a fake user from git author */
|
d61bf88525 | ||
/* User with id == 0 is a fake user from git author */
|
e56139cbf1 | ||
/* User with id == 0 is a fake user from git author */
|
2fc5fe33db | ||
/* User with id == 0 is a fake user from git author */
|
a3458a47e9 | ||
/* User with id == 0 is a fake user from git author */
|
c73bcedb1b | ||
/* User with id == 0 is a fake user from git author */
|
2b2e17494f | ||
/* User with id == 0 is a fake user from git author */
|
273a3f0c77 | ||
/* User with id == 0 is a fake user from git author */
|
a2b499a7b4 | ||
/* User with id == 0 is a fake user from git author */
|
f8fbc66cee | ||
/* User with id == 0 is a fake user from git author */
|
f74469a01c | ||
/* User with id == 0 is a fake user from git author */
|
f2b9005d64 | ||
/* User with id == 0 is a fake user from git author */
|
bda29ec4b3 | ||
/* User with id == 0 is a fake user from git author */
|
effb5f0200 | ||
/* User with id == 0 is a fake user from git author */
|
51f46a76da | ||
/* User with id == 0 is a fake user from git author */
|
23ffdebe25 | ||
/* User with id == 0 is a fake user from git author */
|
9ebd015454 | ||
/* User with id == 0 is a fake user from git author */
|
eebfc2db5e | ||
/* User with id == 0 is a fake user from git author */
|
b44c711708 | ||
/* User with id == 0 is a fake user from git author */
|
a6ba64d149 | ||
/* User with id == 0 is a fake user from git author */
|
7bb03e148d | ||
/* User with id == 0 is a fake user from git author */
|
2b4f3b5007 | ||
/* User with id == 0 is a fake user from git author */
|
8b2d370652 | ||
/* User with id == 0 is a fake user from git author */
|
69bcf4846b | ||
/* User with id == 0 is a fake user from git author */
|
b6d69db347 | ||
/* User with id == 0 is a fake user from git author */
|
dc0ab7c173 | ||
/* User with id == 0 is a fake user from git author */
|
8b2a6e6d4e | ||
/* User with id == 0 is a fake user from git author */
|
43e518b16f | ||
/* User with id == 0 is a fake user from git author */
|
a28897a739 | ||
/* User with id == 0 is a fake user from git author */
|
e00d040a9d | ||
/* User with id == 0 is a fake user from git author */
|
943473ef50 | ||
/* User with id == 0 is a fake user from git author */
|
46de31135c | ||
/* User with id == 0 is a fake user from git author */
|
104ce1f866 | ||
/* User with id == 0 is a fake user from git author */
|
c795e5c62e | ||
/* User with id == 0 is a fake user from git author */
|
3ed8a75620 | ||
/* User with id == 0 is a fake user from git author */
|
ff89c6a6ab | ||
/* User with id == 0 is a fake user from git author */
|
3b17e42092 | ||
/* User with id == 0 is a fake user from git author */
|
5f52208a3f | ||
/* User with id == 0 is a fake user from git author */
|
0ef49bbc47 | ||
/* User with id == 0 is a fake user from git author */
|
024c9d35db | ||
/* User with id == 0 is a fake user from git author */
|
11f325e278 | ||
/* User with id == 0 is a fake user from git author */
|
ccb9f7756b | ||
/* User with id == 0 is a fake user from git author */
|
be00a2991e | ||
/* User with id == 0 is a fake user from git author */
|
2facc77480 | ||
/* User with id == 0 is a fake user from git author */
|
8b62a66e9d | ||
/* User with id == 0 is a fake user from git author */
|
7217785e33 | ||
/* User with id == 0 is a fake user from git author */
|
dd0541c5fa | ||
/* User with id == 0 is a fake user from git author */
|
659daadeaf | ||
/* User with id == 0 is a fake user from git author */
|
80adf8aeb7 | ||
/* User with id == 0 is a fake user from git author */
|
7d83d10fed | ||
/* User with id == 0 is a fake user from git author */
|
3f8ecaef67 | ||
/* User with id == 0 is a fake user from git author */
|
8af9880d23 | ||
/* User with id == 0 is a fake user from git author */
|
4c89ca0c06 | ||
/* User with id == 0 is a fake user from git author */
|
75659d8dbe | ||
/* User with id == 0 is a fake user from git author */
|
6dc1a28af4 | ||
/* User with id == 0 is a fake user from git author */
|
5e7d0deffb | ||
/* User with id == 0 is a fake user from git author */
|
8fda9a017b | ||
/* User with id == 0 is a fake user from git author */
|
a433979bd7 | ||
/* User with id == 0 is a fake user from git author */
|
c8afa6d08a | ||
/* User with id == 0 is a fake user from git author */
|
639c5f8347 | ||
/* User with id == 0 is a fake user from git author */
|
822f54cc50 | ||
/* User with id == 0 is a fake user from git author */
|
9a3bff1103 | ||
/* User with id == 0 is a fake user from git author */
|
48678083ab | ||
/* User with id == 0 is a fake user from git author */
|
e067b495dc | ||
/* User with id == 0 is a fake user from git author */
|
bf00a06e24 |
4761
ZCppMain/ZMainHead.H
Normal file
4761
ZCppMain/ZMainHead.H
Normal file
File diff suppressed because it is too large
Load Diff
997
ZCppMain/ZtCArray.H
Normal file
997
ZCppMain/ZtCArray.H
Normal file
@ -0,0 +1,997 @@
|
||||
|
||||
|
||||
#ifndef __ZTCARRAY_H__
|
||||
#define __ZTCARRAY_H__
|
||||
|
||||
|
||||
#include "ZCppMain/ZMainHead.H"
|
||||
|
||||
|
||||
namespace ZNsMain
|
||||
{
|
||||
|
||||
template< typename Type ,
|
||||
typename TypeArg=const Type&,
|
||||
typename TSize =long
|
||||
>
|
||||
class ZtCArray /////////////////////////
|
||||
{
|
||||
public:
|
||||
typedef TSize TypeSize;
|
||||
typedef Type TypeData;
|
||||
typedef ZtCArray ZCArray ;
|
||||
public:
|
||||
class ZCIterator;
|
||||
public:
|
||||
typedef Type* IterEasy;
|
||||
typedef ZCIterator iterator;
|
||||
typedef const ZCIterator const_iterator;
|
||||
public:
|
||||
|
||||
class ZCIterator
|
||||
{
|
||||
private: mutable
|
||||
Type* mp_Data ; mutable
|
||||
TSize ml_ElePos; // *mp_Data 가 배열에서 차지하는 위치
|
||||
ZCArray* mp_CArray;
|
||||
public:
|
||||
|
||||
ZCIterator()
|
||||
{
|
||||
mp_Data =0;
|
||||
mp_CArray=0;
|
||||
ml_ElePos=0;
|
||||
}/*
|
||||
ZCIterator()*/
|
||||
|
||||
ZCIterator(ZCArray& AR_CArray, Type& AR_CData, TSize AL_ElePos)
|
||||
{
|
||||
mp_Data =&AR_CData ;
|
||||
mp_CArray=&AR_CArray;
|
||||
ml_ElePos=AL_ElePos ;
|
||||
}/*
|
||||
ZCIterator(ZCArray& AR_CArray, Type& AR_CData, TSize AL_ElePos)*/
|
||||
|
||||
ZCIterator(ZCArray& AR_CArray)
|
||||
{
|
||||
mp_Data = AR_CArray.mp_TypeArr ;
|
||||
mp_CArray=&AR_CArray ;
|
||||
ml_ElePos=(AR_CArray.size()>0 ? 1 : 0 ) ;
|
||||
}/*
|
||||
ZCIterator(ZCArray& AR_CArray)*/
|
||||
|
||||
ZCIterator(const ZCArray& AR_CArray)
|
||||
{
|
||||
mp_Data = AR_CArray.mp_TypeArr;
|
||||
mp_CArray=const_cast<ZCArray*>(&AR_CArray);
|
||||
ml_ElePos=(AR_CArray.size()>0 ? 1 : 0 ) ;
|
||||
}/*
|
||||
ZCIterator(const ZCArray& AR_CArray)*/
|
||||
|
||||
Type& operator*( ){return *mp_Data;}
|
||||
Type* operator->(){return mp_Data;}
|
||||
|
||||
const Type& operator* () const{return *mp_Data;}
|
||||
const Type* operator->() const{return mp_Data;}
|
||||
|
||||
ZCIterator& operator++( ){++mp_Data; ++ml_ElePos; return *this;}
|
||||
ZCIterator operator++(int){++mp_Data; ++ml_ElePos; return *this;}
|
||||
|
||||
const ZCIterator& operator++( ) const{++mp_Data; ++ml_ElePos; return *this;}
|
||||
const ZCIterator operator++(int) const{++mp_Data; ++ml_ElePos; return *this;}
|
||||
|
||||
ZCIterator operator+(TSize AL_AddPos) const
|
||||
{
|
||||
return ZCIterator(*this, mp_Data+AL_AddPos, ml_ElePos+AL_AddPos);
|
||||
}/*
|
||||
ZCIterator operator+(TSize AL_AddPos) const*/
|
||||
|
||||
public:
|
||||
};/*
|
||||
class ZCIterator
|
||||
|
||||
public :*/
|
||||
protected:
|
||||
enum{ZEAddSize=20};
|
||||
protected:
|
||||
|
||||
Type* mp_TypeArr ;
|
||||
TypeSize ml_AllSize ;
|
||||
TypeSize ml_UseSize ;
|
||||
TypeSize ml_AddSize ;
|
||||
|
||||
/* TSize ml_AddSize 는 추가 메모리를 지정. 한 개의 원소가 삽입되서
|
||||
재할당해야 할 경우, ml_AddSize 개 만큼을 미리 할당한다.
|
||||
|
||||
protected:*/
|
||||
public :
|
||||
|
||||
|
||||
ZtCArray()
|
||||
{
|
||||
mp_TypeArr =0;
|
||||
ml_AllSize =0;
|
||||
ml_UseSize =0;
|
||||
ml_AddSize =ZEAddSize;
|
||||
}/*
|
||||
ZtCArray()*/
|
||||
|
||||
ZtCArray(const ZtCArray& rhs)
|
||||
{
|
||||
mp_TypeArr =0;
|
||||
ml_AllSize =0;
|
||||
ml_UseSize =0;
|
||||
ml_AddSize =ZEAddSize;
|
||||
|
||||
*this=rhs;
|
||||
}/*
|
||||
ZtCArray(const ZtCArray& rhs)*/
|
||||
|
||||
~ZtCArray()
|
||||
{
|
||||
Delete();
|
||||
}/*
|
||||
~ZtCArray()*/
|
||||
|
||||
ZCArray& operator=(const ZCArray& rhs)
|
||||
{
|
||||
ReAlloc(rhs.ml_UseSize, false);
|
||||
|
||||
ml_UseSize=rhs.ml_UseSize;
|
||||
ml_AllSize=rhs.ml_AllSize;
|
||||
|
||||
for(TypeSize i=0; i<ml_UseSize; ++i)
|
||||
{
|
||||
mp_TypeArr[i]=rhs.mp_TypeArr[i];
|
||||
}/*
|
||||
for(TypeSize i=0; i<ml_UseSize; ++i)*/
|
||||
|
||||
return *this;
|
||||
}/*
|
||||
ZCArray& operator=(const ZCArray& rhs)*/
|
||||
|
||||
ZCArray& operator()(TypeArg AR_TypeArg)
|
||||
{
|
||||
AddTail(AR_TypeArg); return *this;
|
||||
}/*
|
||||
ZCArray& operator()(TypeArg AR_TypeArg)*/
|
||||
|
||||
|
||||
void Delete()
|
||||
{
|
||||
delete [] mp_TypeArr;
|
||||
|
||||
mp_TypeArr =0;
|
||||
ml_AllSize =0;
|
||||
ml_UseSize =0;
|
||||
}/*
|
||||
void Delete()*/
|
||||
|
||||
void clear()
|
||||
{
|
||||
Delete();
|
||||
}/*
|
||||
void clear()*/
|
||||
|
||||
|
||||
TypeSize GetAllSize() const{return ml_AllSize;}
|
||||
TypeSize GetUseSize() const{return ml_UseSize;}
|
||||
TypeSize GetAddSize() const{return ml_AddSize;}
|
||||
|
||||
TypeSize size () const{return ml_UseSize;}
|
||||
TypeSize capacity() const{return ml_AllSize;}
|
||||
|
||||
|
||||
void SetAddSize(TypeSize AL_NewAddSize)
|
||||
{
|
||||
if(AL_NewAddSize>=1) ml_AddSize=AL_NewAddSize;
|
||||
}/*
|
||||
void SetAddSize(TypeSize AL_NewAddSize)*/
|
||||
|
||||
void SetUseSize(TypeSize AL_NewUseSize)
|
||||
{
|
||||
if(AL_NewUseSize>=0 && AL_NewUseSize<=ml_AllSize)
|
||||
{
|
||||
ml_UseSize=AL_NewUseSize;
|
||||
}/*
|
||||
if(AL_NewUseSize>=0 && AL_NewUseSize<=ml_AllSize)*/
|
||||
}/*
|
||||
void SetUseSize(TypeSize AL_NewUseSize)*/
|
||||
|
||||
|
||||
void ReAlloc(TypeSize AL_AllocSize, bool AB_DoKeep=true)
|
||||
{
|
||||
if(AL_AllocSize<1) return ;
|
||||
|
||||
if(AL_AllocSize<ml_AllSize)
|
||||
{
|
||||
return ;
|
||||
}
|
||||
if(AL_AllocSize-ml_AllSize<ml_AddSize)
|
||||
{
|
||||
AL_AllocSize=ml_AllSize+ml_AddSize ;
|
||||
}/*
|
||||
if(AL_AllocSize-ml_AllSize<ml_AddSize)*/
|
||||
|
||||
if(mp_TypeArr==0)
|
||||
{
|
||||
mp_TypeArr =new Type[AL_AllocSize];
|
||||
ml_AllSize =AL_AllocSize ;
|
||||
|
||||
return ;
|
||||
}/*
|
||||
if(mp_TypeArr==0)*/
|
||||
|
||||
if(AB_DoKeep)
|
||||
{
|
||||
Type* VP_ArrType=new Type[AL_AllocSize] ;
|
||||
|
||||
memcpy(VP_ArrType, mp_TypeArr, ml_AllSize*sizeof(Type));
|
||||
|
||||
delete [] mp_TypeArr; mp_TypeArr=VP_ArrType;
|
||||
}
|
||||
else
|
||||
{
|
||||
delete [] mp_TypeArr; mp_TypeArr=new Type[AL_AllocSize] ;
|
||||
}/*
|
||||
else*/
|
||||
|
||||
ml_AllSize=AL_AllocSize;
|
||||
}/*
|
||||
void ReAlloc(TypeSize AL_AllocSize, bool AB_DoKeep=true)*/
|
||||
|
||||
|
||||
// cf) std::vecter<type>::assign(size_type _Count, const type&);
|
||||
|
||||
void assign(TypeSize AL_AllocSize, bool AB_DoKeep=true)
|
||||
{
|
||||
this->ReAlloc(AL_AllocSize, AB_DoKeep);
|
||||
this->SetUseSize(AL_AllocSize);
|
||||
}/*
|
||||
void assign(TypeSize AL_AllocSize, bool AB_DoKeep=true)*/
|
||||
|
||||
|
||||
Type& operator[](TypeSize AL_Index)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
|
||||
if(AL_Index>=ml_UseSize)
|
||||
{
|
||||
std::fstream fileout("DEBUG.txt",std::ios::out | std::ios::app);
|
||||
fileout<<std::endl<<"File : "<<__FILE__<<std::endl<<"Line : "<<__LINE__<<std::endl;
|
||||
fileout<<"Error In 'Type& operator[](TypeSize AL_Index)"<<std::endl;
|
||||
fileout<<" AL_Index>=ml_UseSize"<<", "<<AL_Index<<">="<<ml_UseSize<<std::endl;
|
||||
fileout.close();
|
||||
|
||||
::exit(1);
|
||||
}/*
|
||||
if(AL_Index>=ml_UseSize)*/
|
||||
|
||||
#endif //_DEBUG
|
||||
|
||||
return mp_TypeArr[AL_Index] ;
|
||||
}/*
|
||||
Type& operator[](TypeSize AL_Index)*/
|
||||
|
||||
const Type& operator[](TypeSize AL_Index) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
|
||||
if(AL_Index>=ml_UseSize)
|
||||
{
|
||||
std::fstream fileout("DEBUG.txt", std::ios::out | std::ios::app);
|
||||
fileout<<std::endl<<"File : "<<__FILE__<<std::endl<<"Line : "<<__LINE__<<std::endl;
|
||||
fileout<<"Error In 'const Type& operator[](TypeSize AL_Index) const"<<std::endl;
|
||||
fileout<<" AL_Index>=ml_UseSize"<<std::endl;
|
||||
fileout.close();
|
||||
|
||||
::exit(1);
|
||||
}/*
|
||||
if(AL_Index>=ml_UseSize)*/
|
||||
|
||||
#endif //_DEBUG
|
||||
|
||||
return mp_TypeArr[AL_Index] ;
|
||||
}/*
|
||||
const Type& operator[](TypeSize AL_Index) const*/
|
||||
|
||||
|
||||
Type& GetData(TypeSize AL_Index)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
|
||||
if(AL_Index>=ml_UseSize)
|
||||
{
|
||||
std::fstream fileout("DEBUG.txt",std::ios::out | std::ios::app);
|
||||
fileout<<std::endl<<"File : "<<__FILE__<<std::endl<<"Line : "<<__LINE__<<std::endl;
|
||||
fileout<<"Error In 'Type& GetData(TypeSize AL_Index)"<<std::endl;
|
||||
fileout<<" AL_Index>=ml_UseSize"<<std::endl;
|
||||
fileout.close();
|
||||
|
||||
::exit(1);
|
||||
}/*
|
||||
if(AL_Index>=ml_UseSize)*/
|
||||
|
||||
#endif //_DEBUG
|
||||
|
||||
return mp_TypeArr[AL_Index] ;
|
||||
}/*
|
||||
Type& GetData(TypeSize AL_Index)*/
|
||||
|
||||
const Type& GetData(TypeSize AL_Index) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
|
||||
if(AL_Index>=ml_UseSize)
|
||||
{
|
||||
std::fstream fileout("DEBUG.txt",std::ios::out | std::ios::app);
|
||||
fileout<<std::endl<<"File : "<<__FILE__<<std::endl<<"Line : "<<__LINE__<<std::endl;
|
||||
fileout<<"Error In 'const Type& GetData(TypeSize AL_Index) const"<<std::endl;
|
||||
fileout<<" AL_Index>=ml_UseSize"<<std::endl;
|
||||
fileout.close();
|
||||
|
||||
::exit(1);
|
||||
}/*
|
||||
if(AL_Index>=ml_UseSize)*/
|
||||
|
||||
#endif //_DEBUG
|
||||
|
||||
return mp_TypeArr[AL_Index];
|
||||
}/*
|
||||
const Type& GetData(TypeSize AL_Index) const*/
|
||||
|
||||
|
||||
void AddHead(TypeArg AR_TypeArg)
|
||||
{
|
||||
ReAlloc((ml_UseSize++)+1);
|
||||
|
||||
for(TypeSize i=ml_UseSize-2; i>=0; --i)
|
||||
{
|
||||
mp_TypeArr[i+1]=mp_TypeArr[i] ;
|
||||
}/*
|
||||
for(TypeSize i=ml_UseSize-2; i>=0; --i)*/
|
||||
|
||||
mp_TypeArr[0]=AR_TypeArg ;
|
||||
}/*
|
||||
void AddHead(TypeArg AR_TypeArg)*/
|
||||
|
||||
Type& AddHead()
|
||||
{
|
||||
// 앞에 빈 원소를 삽입하고 그 원소를 반환한다.
|
||||
|
||||
ReAlloc((ml_UseSize++)+1);
|
||||
|
||||
for(TypeSize i=ml_UseSize-2; i>=0; --i)
|
||||
{
|
||||
mp_TypeArr[i+1]=mp_TypeArr[i] ;
|
||||
}/*
|
||||
for(TypeSize i=ml_UseSize-2; i>=0; --i)*/
|
||||
|
||||
return mp_TypeArr[0] ;
|
||||
}/*
|
||||
Type& AddHead()*/
|
||||
|
||||
void AddTail(TypeArg AR_TypeArg)
|
||||
{
|
||||
ReAlloc((ml_UseSize++)+1); mp_TypeArr[ml_UseSize-1]=AR_TypeArg ;
|
||||
}/*
|
||||
void AddTail(TypeArg AR_TypeArg)*/
|
||||
|
||||
Type& AddTail()
|
||||
{
|
||||
// 끝에 빈 원소를 삽입하고 그 원소를 반환한다.
|
||||
|
||||
ReAlloc((ml_UseSize++)+1); return mp_TypeArr[ml_UseSize-1];
|
||||
}/*
|
||||
Type& AddTail()*/
|
||||
|
||||
operator Type&()
|
||||
{
|
||||
return AddTail();
|
||||
}/*
|
||||
operator Type&()*/
|
||||
|
||||
|
||||
void push_back(TypeArg AR_TypeArg)
|
||||
{
|
||||
AddTail(AR_TypeArg);
|
||||
}/*
|
||||
void push_back(TypeArg AR_TypeArg)*/
|
||||
|
||||
Type& push_back()
|
||||
{
|
||||
return AddTail();
|
||||
}/*
|
||||
Type& push_back()*/
|
||||
|
||||
ZCIterator begin()
|
||||
{
|
||||
return ZCIterator(*this);
|
||||
}/*
|
||||
ZCIterator begin()*/
|
||||
|
||||
const ZCIterator begin() const
|
||||
{
|
||||
return ZCIterator(*this);
|
||||
}/*
|
||||
const ZCIterator begin() const*/
|
||||
|
||||
|
||||
template<typename TFunctor> void IterElement(TFunctor AO_Functor)
|
||||
{
|
||||
Type* VP_TypeArr = mp_TypeArr;
|
||||
|
||||
__for0(TypeSize, i, ml_UseSize)
|
||||
{
|
||||
ZNsMain::ZtCTypeData<TFunctor>::
|
||||
GetObjRef(AO_Functor)( *VP_TypeArr );
|
||||
|
||||
++VP_TypeArr;
|
||||
|
||||
/* ZtCTypeData 으로 인해서, AO_Functor 이 함수일 때 뿐이 아니라,
|
||||
operator() 연산자를 가진 object 포인터일 때도 사용할 수 있게 되었다.
|
||||
*/
|
||||
}/*
|
||||
__for0(TypeSize, i, ml_UseSize)*/
|
||||
}/*
|
||||
template<typename TFunctor> void IterElement(TFunctor AO_Functor)*/
|
||||
|
||||
template<typename TFunctor, typename TTypeHelp>
|
||||
void IterElement(TFunctor AO_Functor, TTypeHelp AO_TypeHelp)
|
||||
{
|
||||
/*/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
■ TTypeHelp 가 class 일 경우, 크기가 커서 참조로 넘어가야 한다면,
|
||||
|
||||
IterElement<myFunctor, myClass&>(myFunctor_obj, myClass_Obj);
|
||||
|
||||
의 형태로 호출할 게 아니라, ZNsMain::ZtCObjectPtr<> 을 사용하여,
|
||||
|
||||
myClass myClass_Obj;
|
||||
|
||||
ZNsMain::ZtCObjectPtr<myClass> myCObjPtr(myClass_Obj);
|
||||
|
||||
나
|
||||
|
||||
IterElement(myFunctor_obj,
|
||||
ZNsMain::ZtCObjectPtr<myClass>(myClass_Obj));
|
||||
|
||||
형태를 사용하면 좋을 것 같다. -- 2014-06-16 23:11:00
|
||||
|
||||
|
||||
ZCCheckRef::PassData() 으로 인해, 인수를 ZtCRef 클래스를 이용해 인수를 참조
|
||||
로 넘길 수 있게 되었다. -- 2021-03-10 16:56
|
||||
|
||||
이제는 ZtCRef 과 ZCCheckRef 클래스 템플릿을 사용하면 된다. -- 2021-03-11 11:00
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
typedef ZNsMain::
|
||||
ZtCCheckRef<TTypeHelp> ZCCheckRef;
|
||||
|
||||
Type* VP_TypeArr = mp_TypeArr;
|
||||
|
||||
__for0(TypeSize, i, ml_UseSize)
|
||||
{
|
||||
ZNsMain::ZtCTypeData<TFunctor>::GetObjRef(AO_Functor)
|
||||
(
|
||||
*VP_TypeArr, ZCCheckRef::PassData(AO_TypeHelp)
|
||||
);
|
||||
++VP_TypeArr; ///////////////////////////////////////
|
||||
}/*
|
||||
__for0(TypeSize, i, ml_UseSize)*/
|
||||
}/*
|
||||
template<typename TFunctor, typename TTypeHelp>
|
||||
void IterElement(TFunctor AO_Functor, TTypeHelp AO_TypeHelp)*/
|
||||
|
||||
|
||||
template<typename TFunctor, typename TTypeHelp1, typename TTypeHelp2>
|
||||
void IterElement(TFunctor AO_Functor,
|
||||
TTypeHelp1 AO_TypeHelp1, TTypeHelp2 AO_TypeHelp2)
|
||||
{
|
||||
/*/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
■ TTypeHelp 가 class 일 경우, 크기가 커서 참조로 넘어가야 한다면,
|
||||
|
||||
IterElement<myFunctor, myClass&>(myFunctor_obj, myClass_Obj);
|
||||
|
||||
의 형태로 호출할 게 아니라, ZNsMain::ZtCObjectPtr<> 을 사용하여,
|
||||
|
||||
myClass myClass_Obj; ZNsMain::ZtCObjectPtr<myClass> myCObjPtr(myClass_Obj);
|
||||
|
||||
나
|
||||
|
||||
IterElement(myFunctor_obj, ZNsMain::ZtCObjectPtr<myClass>(myClass_Obj));
|
||||
|
||||
형태를 사용하면 좋을 것 같다. -- 2014-06-16 23:11:00
|
||||
|
||||
|
||||
ZCCheckRef::PassData() 으로 인해, 인수를 ZtCRef 클래스를 이용해 인수를 참조
|
||||
로 넘길 수 있게 되었다. -- 2021-03-10 16:56
|
||||
|
||||
이제는 ZtCRef 과 ZCCheckRef 클래스 템플릿을 사용하면 된다. -- 2021-03-11 11:00
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
typedef ZNsMain::ZtCCheckRef<TTypeHelp1> ZCCheckRef1;
|
||||
typedef ZNsMain::ZtCCheckRef<TTypeHelp2> ZCCheckRef2;
|
||||
|
||||
Type* VP_TypeArr = mp_TypeArr;
|
||||
|
||||
__for0(TypeSize, i, ml_UseSize)
|
||||
{
|
||||
ZNsMain::ZtCTypeData<TFunctor>::GetObjRef(AO_Functor)
|
||||
(
|
||||
*VP_TypeArr
|
||||
, ZCCheckRef1::PassData(AO_TypeHelp1)
|
||||
, ZCCheckRef2::PassData(AO_TypeHelp2)
|
||||
);
|
||||
++VP_TypeArr; ///////////////////////////////////////
|
||||
}/*
|
||||
__for0(TypeSize, i, ml_UseSize)*/
|
||||
}/*
|
||||
template<typename TFunctor, typename TTypeHelp1, typename TTypeHelp2>
|
||||
void IterElement(TFunctor AO_Functor,
|
||||
TTypeHelp1 AO_TypeHelp1, TTypeHelp2 AO_TypeHelp2)*/
|
||||
|
||||
|
||||
/*///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
■ IterElement() 예제.
|
||||
|
||||
#include <iostream>
|
||||
#include "ZCArray.H"
|
||||
|
||||
using namespace std ;
|
||||
using namespace ZNsMain;
|
||||
|
||||
int main()
|
||||
{
|
||||
std:: ZtCArray<int> myArray;
|
||||
|
||||
myArray.AddTail(10);
|
||||
myArray.AddTail(20);
|
||||
myArray.AddTail(30);
|
||||
myArray.AddTail(40);
|
||||
|
||||
struct StFunctor
|
||||
{
|
||||
static void ShowElement(int ArgiValue){cout<<"# Value="<<ArgiValue<<endl;}
|
||||
};
|
||||
|
||||
myArray.IterElement(StFunctor::ShowElement);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
■ -- 2014-06-16 23:34:00
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
/*///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
■ 순차적으로 각 원소를 순회할 수 있는 자료 구조, 즉 리스트나 배열 클래스는
|
||||
|
||||
MoveNextIter(), MovePrevIter()
|
||||
|
||||
멤버를 갖는 것으로 정했다. stl 의 반복자는 너무 일반화하다보니, 성능 상의
|
||||
제약이 발생한 것 같다.
|
||||
|
||||
-- 2011-06-07 20:25:00
|
||||
|
||||
GetDataInIter() 를 추가했다.
|
||||
|
||||
-- 2011-06-12 20:42:00
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
Type* GetHeadIterEasy (){return mp_TypeArr ;}
|
||||
Type* GetTailIterEasy (){return mp_TypeArr+ml_UseSize-1 ;}
|
||||
IterEasyID GetHeadIterEasyID(){return (IterEasyID) mp_TypeArr ;}
|
||||
IterEasyID GetTailIterEasyID(){return (IterEasyID)(mp_TypeArr+ml_UseSize-1);}
|
||||
|
||||
const Type* GetHeadIterEasy () const{return mp_TypeArr ;}
|
||||
const Type* GetTailIterEasy () const{return mp_TypeArr+ml_UseSize-1 ;}
|
||||
const IterEasyID GetHeadIterEasyID() const{return (IterEasyID) mp_TypeArr ;}
|
||||
const IterEasyID GetTailIterEasyID() const{return (IterEasyID)(mp_TypeArr+ml_UseSize-1);}
|
||||
|
||||
IterEasyID ItHead() {return GetHeadIterEasyID();}
|
||||
IterEasyID ItTail() {return GetTailIterEasyID();}
|
||||
|
||||
const IterEasyID ItHead() const{return GetHeadIterEasyID();}
|
||||
const IterEasyID ItTail() const{return GetTailIterEasyID();}
|
||||
|
||||
|
||||
void MoveNextIter(Type*& APR_CType) const
|
||||
{
|
||||
++APR_CType;
|
||||
}/*
|
||||
void MoveNextIter(Type*& APR_CType) const*/
|
||||
|
||||
void MoveNextIter(iterator& ARR_CIterator) const
|
||||
{
|
||||
++ARR_CIterator;
|
||||
}/*
|
||||
void MoveNextIter(iterator& ARR_CIterator) const*/
|
||||
|
||||
void MoveNextIter(IterEasyID& AI_IterEasyID) const
|
||||
{
|
||||
MoveNextIter((Type*&)AI_IterEasyID);
|
||||
}/*
|
||||
void MoveNextIter(IterEasyID& AI_IterEasyID) const*/
|
||||
|
||||
void MoveNextIter(const Type*& APR_CType) const
|
||||
{
|
||||
++APR_CType;
|
||||
}/*
|
||||
void MoveNextIter(const Type*& APR_CType) const*/
|
||||
|
||||
void MoveNextIter(const iterator& ARR_CIterator) const
|
||||
{
|
||||
++ARR_CIterator;
|
||||
}/*
|
||||
void MoveNextIter(const iterator& ARR_CIterator) const*/
|
||||
|
||||
void MoveNextIter(const IterEasyID& AI_IterEasyID) const
|
||||
{
|
||||
MoveNextIter((const Type*&)AI_IterEasyID);
|
||||
}/*
|
||||
void MoveNextIter(const IterEasyID& AI_IterEasyID) const*/
|
||||
|
||||
|
||||
void MovePrevIter(Type*& APR_CType) const
|
||||
{
|
||||
--APR_CType;
|
||||
}/*
|
||||
void MovePrevIter(Type*& APR_CType) const*/
|
||||
|
||||
void MovePrevIter(iterator& ARR_CIterator) const
|
||||
{
|
||||
--ARR_CIterator;
|
||||
}/*
|
||||
void MovePrevIter(iterator& ARR_CIterator) const*/
|
||||
|
||||
void MovePrevIter(IterEasyID& AI_IterEasyID) const
|
||||
{
|
||||
MovePrevIter((Type*&)AI_IterEasyID);
|
||||
}/*
|
||||
void MovePrevIter(IterEasyID& AI_IterEasyID) const*/
|
||||
|
||||
void MovePrevIter(const Type*& APR_CType) const
|
||||
{
|
||||
--APR_CType;
|
||||
}/*
|
||||
void MovePrevIter(const Type*& APR_CType)*/
|
||||
|
||||
void MovePrevIter(const iterator& ARR_CIterator) const
|
||||
{
|
||||
--ARR_CIterator;
|
||||
}/*
|
||||
void MovePrevIter(const iterator& ARR_CIterator) const*/
|
||||
|
||||
void MovePrevIter(const IterEasyID& AI_IterEasyID) const
|
||||
{
|
||||
MovePrevIter((const Type*&)AI_IterEasyID);
|
||||
}/*
|
||||
void MovePrevIter(const IterEasyID& AI_IterEasyID) const*/
|
||||
|
||||
|
||||
Type& GetDataInIter(Type* AP_CType)
|
||||
{
|
||||
return *AP_CType;
|
||||
}/*
|
||||
Type& GetDataInIter(Type* AP_CType)*/
|
||||
|
||||
Type& GetDataInIter(iterator& ARR_CIterator)
|
||||
{
|
||||
return *ARR_CIterator;
|
||||
}/*
|
||||
Type& GetDataInIter(iterator& ARR_CIterator)*/
|
||||
|
||||
Type& GetDataInIter(IterEasyID AI_IterEasyID)
|
||||
{
|
||||
return *(Type*)AI_IterEasyID;
|
||||
}/*
|
||||
Type& GetDataInIter(IterEasyID AI_IterEasyID)*/
|
||||
|
||||
const Type& GetDataInIter(const Type* AP_CType) const
|
||||
{
|
||||
return *AP_CType;
|
||||
}/*
|
||||
const Type& GetDataInIter(const Type* AP_CType) const*/
|
||||
|
||||
const Type& GetDataInIter(const iterator& ARR_CIterator) const
|
||||
{
|
||||
return *ARR_CIterator;
|
||||
}/*
|
||||
const Type& GetDataInIter(const iterator& ARR_CIterator) const*/
|
||||
|
||||
const Type& GetDataInIter(const IterEasyID AI_IterEasyID) const
|
||||
{
|
||||
return *(const Type*)AI_IterEasyID;
|
||||
}/*
|
||||
const Type& GetDataInIter(const IterEasyID AI_IterEasyID) const*/
|
||||
|
||||
|
||||
Type& GetDataInIter(Type* AP_Type, TypeSize AI_FarNum)
|
||||
{
|
||||
return *(AP_Type + AI_FarNum);
|
||||
}/*
|
||||
Type& GetDataInIter(Type* AP_Type, TypeSize AI_FarNum)*/
|
||||
|
||||
Type& GetDataInIter(iterator& ARR_CIterator, TypeSize AI_FarNum)
|
||||
{
|
||||
return *(ARR_CIterator+AI_FarNum);
|
||||
}/*
|
||||
Type& GetDataInIter(iterator& ARR_CIterator, TypeSize AI_FarNum)*/
|
||||
|
||||
Type& GetDataInIter(IterEasyID ARRI_IterEasyID, TypeSize AI_FarNum)
|
||||
{
|
||||
return GetDataInIter((Type*)ARRI_IterEasyID, AI_FarNum);
|
||||
}/*
|
||||
Type& GetDataInIter(IterEasyID ARRI_IterEasyID, TypeSize AI_FarNum)*/
|
||||
|
||||
|
||||
const Type& GetDataInIter(const Type* AP_Type, TypeSize AI_FarNum) const
|
||||
{
|
||||
return *(AP_Type + AI_FarNum);
|
||||
}/*
|
||||
const Type& GetDataInIter(const Type* AP_Type, TypeSize AI_FarNum) const*/
|
||||
|
||||
const Type& GetDataInIter(iterator& ARR_CIterator, TypeSize AI_FarNum) const
|
||||
{
|
||||
return *(ARR_CIterator+AI_FarNum);
|
||||
}/*
|
||||
const Type& GetDataInIter(iterator& ARR_CIterator, TypeSize AI_FarNum) const*/
|
||||
|
||||
const Type& GetDataInIter(const IterEasyID ARRI_IterEasyID, TypeSize AI_FarNum) const
|
||||
{
|
||||
return GetDataInIter((const Type*)ARRI_IterEasyID, AI_FarNum);
|
||||
}/*
|
||||
const Type& GetDataInIter(const IterEasyID ARRI_IterEasyID, TypeSize AI_FarNum) const*/
|
||||
|
||||
|
||||
// 아래 ItD() 함수는 GetDataInIter() 를 짧게 줄인 것이다.
|
||||
|
||||
Type& ItD(Type* AP_Type ){return GetDataInIter(AP_Type );}
|
||||
Type& ItD(iterator& ARR_CIterator ){return GetDataInIter(ARR_CIterator );}
|
||||
Type& ItD(IterEasyID ARRI_IterEasyID ){return GetDataInIter(ARRI_IterEasyID );}
|
||||
Type& ItD(Type* AP_Type , TypeSize AI_FarNum){return GetDataInIter(AP_Type , AI_FarNum );}
|
||||
Type& ItD(iterator& ARR_CIterator , TypeSize AI_FarNum){return GetDataInIter(ARR_CIterator , AI_FarNum);}
|
||||
Type& ItD(IterEasyID ARRI_IterEasyID, TypeSize AI_FarNum){return GetDataInIter(ARRI_IterEasyID, AI_FarNum);}
|
||||
|
||||
const Type& ItD(const Type* AP_Type ) const{return GetDataInIter(AP_Type );}
|
||||
const Type& ItD(const iterator& ARR_CIterator ) const{return GetDataInIter(ARR_CIterator );}
|
||||
const Type& ItD(const IterEasyID ARRI_IterEasyID ) const{return GetDataInIter(ARRI_IterEasyID );}
|
||||
const Type& ItD(const Type* AP_Type , TypeSize AI_FarNum) const{return GetDataInIter(AP_Type );}
|
||||
const Type& ItD(const iterator& ARR_CIterator , TypeSize AI_FarNum) const{return GetDataInIter(ARR_CIterator , AI_FarNum);}
|
||||
const Type& ItD(const IterEasyID ARRI_IterEasyID, TypeSize AI_FarNum) const{return GetDataInIter(ARRI_IterEasyID, AI_FarNum);}
|
||||
|
||||
public:
|
||||
};/*
|
||||
template< typename Type ,
|
||||
typename TypeArg=const Type&,
|
||||
typename TSize =long
|
||||
>
|
||||
class ZtCArray ////////////////////////*/
|
||||
|
||||
|
||||
//////////////////////////////////////////////
|
||||
|
||||
////////////// end class ZCArray //////////////
|
||||
|
||||
//////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
/*////////////////////////////////////////////////////////////////////
|
||||
|
||||
■ class ZtCArrayFixed<> 는 배열 메모리를 자체 할당하지 않고,
|
||||
이미 외부에서 new 나 정적으로 선언되어 있는 배열을 사용한다.
|
||||
따라서 ZtCArrayFixed<> 내부에서 임의로 배열 크기를 조절할 수 없다.
|
||||
|
||||
-- 2011-08-05 20:40:00
|
||||
|
||||
////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
template< typename Type,
|
||||
typename TSize=long
|
||||
>
|
||||
class ZtCArrayFixed ///////////
|
||||
{
|
||||
public:
|
||||
typedef Type TypeData;
|
||||
public:
|
||||
typedef const Type* const_iterator;
|
||||
typedef Type* iterator;
|
||||
private:
|
||||
Type* mp_TypeArr;
|
||||
TSize ml_UseSize;
|
||||
public:
|
||||
|
||||
ZtCArrayFixed()
|
||||
{
|
||||
Init(0, 0);
|
||||
}
|
||||
ZtCArrayFixed(TypeData* AP_DataArr, TSize AL_ArrSize)
|
||||
{
|
||||
Init(AP_DataArr, AL_ArrSize);
|
||||
}
|
||||
void Init(TypeData* AP_DataArr, TSize AL_ArrSize)
|
||||
{
|
||||
mp_TypeArr=AP_DataArr;
|
||||
ml_UseSize=AL_ArrSize;
|
||||
}/*
|
||||
void Init(TypeData* AP_DataArr,TSize AL_ArrSize)*/
|
||||
|
||||
TSize size() const{return ml_UseSize;}
|
||||
|
||||
|
||||
Type& operator[](TSize AL_Index)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
|
||||
if(AL_Index>=ml_UseSize)
|
||||
{
|
||||
std::fstream fileout("DEBUG.txt",std::ios::out | std::ios::app);
|
||||
fileout<<std::endl<<"File : "<<__FILE__<<std::endl<<"Line : "<<__LINE__<<std::endl;
|
||||
fileout<<"Error In 'Type& operator[](TSize AL_Index)"<<std::endl;
|
||||
fileout<<" AL_Index>=ml_UseSize"<<", "<<AL_Index<<">="<<ml_UseSize<<std::endl;
|
||||
fileout.close();
|
||||
|
||||
::exit(1);
|
||||
}/*
|
||||
if(AL_Index>=ml_UseSize)*/
|
||||
|
||||
#endif //_DEBUG
|
||||
|
||||
return mp_TypeArr[AL_Index] ;
|
||||
}/*
|
||||
Type& operator[](TSize AL_Index)*/
|
||||
|
||||
const Type& operator[](TSize AL_Index) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
|
||||
if(AL_Index>=ml_UseSize)
|
||||
{
|
||||
std::fstream fileout("DEBUG.txt",std::ios::out | std::ios::app);
|
||||
fileout<<std::endl<<"File : "<<__FILE__<<std::endl<<"Line : "<<__LINE__<<std::endl;
|
||||
fileout<<"Error In 'const Type& operator[](TSize AL_Index) const"<<std::endl;
|
||||
fileout<<" AL_Index>=ml_UseSize"<<std::endl;
|
||||
fileout.close();
|
||||
|
||||
::exit(1);
|
||||
}/*
|
||||
if(AL_Index>=ml_UseSize)*/
|
||||
|
||||
#endif //_DEBUG
|
||||
|
||||
return mp_TypeArr[AL_Index] ;
|
||||
}/*
|
||||
const Type& operator[](TSize AL_Index) const*/
|
||||
|
||||
|
||||
Type& GetData(TSize AL_Index)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
|
||||
if(AL_Index>=ml_UseSize)
|
||||
{
|
||||
std::fstream fileout("DEBUG.txt",std::ios::out | std::ios::app);
|
||||
fileout<<std::endl<<"File : "<<__FILE__<<std::endl<<"Line : "<<__LINE__<<std::endl;
|
||||
fileout<<"Error In 'Type& GetData(TSize AL_Index)"<<std::endl;
|
||||
fileout<<" AL_Index>=ml_UseSize"<<std::endl;
|
||||
fileout.close();
|
||||
|
||||
::exit(1);
|
||||
}/*
|
||||
if(AL_Index>=ml_UseSize)*/
|
||||
|
||||
#endif //_DEBUG
|
||||
|
||||
return mp_TypeArr[AL_Index] ;
|
||||
}/*
|
||||
Type& GetData(TSize AL_Index)*/
|
||||
|
||||
const Type& GetData(TSize AL_Index) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
|
||||
if(AL_Index>=ml_UseSize)
|
||||
{
|
||||
std::fstream fileout("DEBUG.txt",std::ios::out | std::ios::app);
|
||||
fileout<<std::endl<<"File : "<<__FILE__<<std::endl<<"Line : "<<__LINE__<<std::endl;
|
||||
fileout<<"Error In 'const Type& GetData(TSize AL_Index) const"<<std::endl;
|
||||
fileout<<" AL_Index>=ml_UseSize"<<std::endl;
|
||||
fileout.close();
|
||||
|
||||
::exit(1);
|
||||
}/*
|
||||
if(AL_Index>=ml_UseSize)*/
|
||||
|
||||
#endif //_DEBUG
|
||||
|
||||
return mp_TypeArr[AL_Index];
|
||||
}/*
|
||||
const Type& GetData(TSize AL_Index) const*/
|
||||
|
||||
|
||||
Type* begin() { return mp_TypeArr; }
|
||||
const Type* begin() const { return mp_TypeArr; }
|
||||
|
||||
|
||||
void MoveNextIter(Type*& ARR_CIterator) const
|
||||
{
|
||||
++ARR_CIterator;
|
||||
}/*
|
||||
void MoveNextIter(Type*& ARR_CIterator) const*/
|
||||
|
||||
void MovePrevIter(iterator& ARR_CIterator)
|
||||
{
|
||||
--ARR_CIterator;
|
||||
}/*
|
||||
void MovePrevIter(iterator& ARR_CIterator)*/
|
||||
|
||||
|
||||
void MoveNextIter(const_iterator& ARR_CIterator) const
|
||||
{
|
||||
++ARR_CIterator;
|
||||
}/*
|
||||
void MoveNextIter(const_iterator& ARR_CIterator) const*/
|
||||
|
||||
void MovePrevIter(const_iterator& ARR_CIterator) const
|
||||
{
|
||||
--ARR_CIterator;
|
||||
}/*
|
||||
void MovePrevIter(const_iterator& ARR_CIterator) const*/
|
||||
|
||||
/*////////////////////////////////////////////////////
|
||||
|
||||
위 코드를 아래로 하면 안된다.
|
||||
|
||||
void MoveNextIter(const iterator& ARR_CIterator) const
|
||||
{
|
||||
++ARR_CIterator;
|
||||
}
|
||||
//void MoveNextIter(const iterator& ARR_CIterator) const
|
||||
|
||||
void MovePrevIter(const iterator& ARR_CIterator) const
|
||||
{
|
||||
--ARR_CIterator;
|
||||
}
|
||||
//void MovePrevIter(const iterator& ARR_CIterator) const
|
||||
|
||||
const iterator 는 Type const * const 이지 Type const * 가 아니다.
|
||||
|
||||
-- 2011-08-05 23:49:00
|
||||
|
||||
////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
Type& GetDataInIter(iterator& ARR_CIterator)
|
||||
{
|
||||
return *ARR_CIterator;
|
||||
}/*
|
||||
Type& GetDataInIter(iterator& ARR_CIterator)*/
|
||||
|
||||
const Type& GetDataInIter(const_iterator& ARR_CIterator) const
|
||||
{
|
||||
return *ARR_CIterator;
|
||||
}/*
|
||||
const Type& GetDataInIter(const_iterator& ARR_CIterator) const*/
|
||||
|
||||
|
||||
public:
|
||||
};/*
|
||||
template< typename Type,
|
||||
typename TSize=long
|
||||
>
|
||||
class ZtCArrayFixed /////////*/
|
||||
|
||||
}/*
|
||||
namespace ZNsMain*/
|
||||
|
||||
|
||||
#endif //__ZTCARRAY_H__
|
3295
ZCppMain/ZtCObjList.H
Normal file
3295
ZCppMain/ZtCObjList.H
Normal file
File diff suppressed because it is too large
Load Diff
15
ZCppMain/ZtCSortObjList.H
Normal file
15
ZCppMain/ZtCSortObjList.H
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
|
||||
#include "ZCppMain/ZMainHead.H"
|
||||
|
||||
|
||||
namespace ZNsMain
|
||||
{
|
||||
|
||||
template<typename TypeObjList> class ZtCSortObjList
|
||||
{
|
||||
};/*
|
||||
template<typename TypeObjList> class ZtCSortObjList*/
|
||||
|
||||
}/*
|
||||
namespace ZNsMain*/
|
242
ZCppMain/test.cpp
Normal file
242
ZCppMain/test.cpp
Normal file
@ -0,0 +1,242 @@
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include "ZCppMain/ZtCArray.H"
|
||||
#include "ZCppMain/ZtCObjList.H"
|
||||
|
||||
|
||||
using namespace std ;
|
||||
using namespace ZNsMain ;
|
||||
|
||||
|
||||
namespace ZNsMain{namespace ZNsHide
|
||||
{
|
||||
|
||||
class ZCFunctor1
|
||||
{
|
||||
private:
|
||||
ZTypInt mi_Index;
|
||||
public :
|
||||
|
||||
ZCFunctor1(){mi_Index=0;}
|
||||
|
||||
void operator()(int ArgiValue)
|
||||
{ cout<<"# index="<<++mi_Index<<", Value="<<ArgiValue<<endl; }
|
||||
public :
|
||||
};/*
|
||||
class ZCFunctor1*/
|
||||
|
||||
}/*
|
||||
namespace ZNsHide*/}/*namespace ZNsMain*/
|
||||
|
||||
|
||||
template<typename T> class ZtCMy
|
||||
{ public: enum{EMyNum=10}; typedef T TypeData; };
|
||||
|
||||
template<typename T> class ZtCMy< ZNsMain::ZtCObjList<T> >
|
||||
{ public: enum{EMyNum=20}; typedef T TypeData; };
|
||||
|
||||
|
||||
int main(int ArgiCnt, char** AppArgu)
|
||||
{
|
||||
cout<<endl<<"!!! C++'s Great Start -- 2021-03-08 11:10:00 !!!"<<endl<<endl;
|
||||
|
||||
|
||||
typedef ZNsMain::ZtCObjList<int> CListByInt;
|
||||
typedef ZNsMain::ZtCArray <int> CArrayInt ;
|
||||
|
||||
typedef ZtCMy<int> CMy1;
|
||||
typedef ZtCMy<CListByInt> CMy2;
|
||||
typedef ZtCMy<CArrayInt > CMy3;
|
||||
|
||||
cout<<"# CMy1::EMyNum="<<CMy1::EMyNum<<endl;
|
||||
cout<<"# CMy2::EMyNum="<<CMy2::EMyNum<<endl;
|
||||
cout<<"# CMy3::EMyNum="<<CMy3::EMyNum<<endl;
|
||||
|
||||
cout<<"# CMy1::TypeData="<<typeid(CMy1::TypeData).name()<<endl;
|
||||
cout<<"# CMy2::TypeData="<<typeid(CMy2::TypeData).name()<<endl;
|
||||
cout<<"# CMy3::TypeData="<<typeid(CMy3::TypeData).name()<<endl;
|
||||
/*
|
||||
# CMy1::EMyNum=10
|
||||
# CMy2::EMyNum=20
|
||||
# CMy3::EMyNum=10
|
||||
# CMy1::TypeData=int
|
||||
# CMy2::TypeData=int
|
||||
# CMy3::TypeData=class ZNsMain::ZtCArray<int,int const &,long>
|
||||
*/
|
||||
|
||||
cout<<"# int ="<<typeid(int).name()<<endl;
|
||||
cout<<"# int*="<<typeid(int*).name()<<endl;
|
||||
cout<<"# int&="<<typeid(int&).name()<<endl;
|
||||
|
||||
int i1= 10;
|
||||
int* i2=&i1;
|
||||
int& i3= i1;
|
||||
|
||||
cout<<"# int ="<<typeid(i1).name()<<endl;
|
||||
cout<<"# int*="<<typeid(i2).name()<<endl;
|
||||
cout<<"# int&="<<typeid(i3).name()<<endl;
|
||||
|
||||
typedef int HereInt1;
|
||||
typedef int* HereInt2;
|
||||
typedef int& HereInt3;
|
||||
|
||||
HereInt1 myi1= 100 ;
|
||||
HereInt2 myi2= &myi1;
|
||||
HereInt3 myi3= myi1 ; myi3=123;
|
||||
|
||||
ZtCRef<int> myref(myi1);
|
||||
ZtCCheckRef< int > myrefcheck1(myi1); myrefcheck1.GetData();
|
||||
ZtCCheckRef< ZtCRef<int> > myrefcheck2(myi1); myrefcheck2.GetData();
|
||||
|
||||
myi1=4321;
|
||||
|
||||
cout<<"# myrefcheck1.GetData()="<<myrefcheck1.GetData()<<endl;
|
||||
cout<<"# myrefcheck2.GetData()="<<myrefcheck2.GetData()<<endl;
|
||||
|
||||
cout<<"# HereInt1 ="<< typeid(myi1).name()<<endl;
|
||||
cout<<"# HereInt2 int* ="<< typeid(myi2).name()<<endl;
|
||||
cout<<"# HereInt3 int& ="<< typeid(myi3).name()<<endl;
|
||||
|
||||
#ifdef __WIN
|
||||
cout<<"# HereInt1 hash="<< typeid(myi1).hash_code()<<endl;
|
||||
cout<<"# HereInt2 hash="<< typeid(myi2).hash_code()<<endl;
|
||||
cout<<"# HereInt3 hash="<< typeid(myi3).hash_code()<<endl;
|
||||
|
||||
cout<<"# HereInt1 raw ="<< typeid(myi1).raw_name()<<endl;
|
||||
cout<<"# HereInt2 raw ="<< typeid(myi2).raw_name()<<endl;
|
||||
cout<<"# HereInt3 raw ="<< typeid(myi3).raw_name()<<endl;
|
||||
#endif
|
||||
|
||||
cout<<"# HereInt1 ="<< myi1<<endl;
|
||||
cout<<"# HereInt2 int* ="<<*myi2<<endl;
|
||||
cout<<"# HereInt3 int& ="<< myi3<<endl;
|
||||
/*
|
||||
# HereInt1 =int
|
||||
# HereInt2 int* =int *
|
||||
# HereInt3 int& =int
|
||||
|
||||
# HereInt1 hash=3440116983
|
||||
# HereInt2 hash=2450196518
|
||||
# HereInt3 hash=3440116983
|
||||
|
||||
# HereInt1 raw =.H
|
||||
# HereInt2 raw =.PAH
|
||||
# HereInt3 raw =.H
|
||||
|
||||
# HereInt1 =123
|
||||
# HereInt2 int* =123
|
||||
# HereInt3 int& =123
|
||||
*/
|
||||
|
||||
CListByInt VO_IntList;
|
||||
CArrayInt VO_IntArr ;
|
||||
|
||||
VO_IntList.AddTail(10);
|
||||
VO_IntList.AddTail(40);
|
||||
VO_IntList.AddTail(20);
|
||||
VO_IntList.AddTail(80);
|
||||
VO_IntList.AddTail(90);
|
||||
|
||||
VO_IntArr.AddTail(123);
|
||||
VO_IntArr.AddTail(153);
|
||||
VO_IntArr.AddTail(543);
|
||||
VO_IntArr.AddTail(553);
|
||||
VO_IntArr.AddTail(983);
|
||||
|
||||
|
||||
|
||||
typedef ZNsMain::ZtStTuple<int, ZNsMain::ZtCRef<int> > ZStTuple2;
|
||||
|
||||
int i=1;
|
||||
int& j=i;
|
||||
|
||||
ZStTuple2 VO_ZStTuple2 = ZNsMain::ZftMakeArguTuple<int, ZNsMain::ZtCRef<int> >
|
||||
(i, ZNsMain::ZtCRef<int>(j).GetData() );
|
||||
|
||||
VO_ZStTuple2._2 = 3;
|
||||
|
||||
|
||||
|
||||
typedef ZtStTuple<int, int> ZCTuple;
|
||||
|
||||
ZCTuple VO_CTuple; VO_CTuple._1 = 1;
|
||||
|
||||
|
||||
_FFS_(ZCShowData1)
|
||||
(ZTypInt AiInt)
|
||||
{
|
||||
cout<<"# Elem1 : "<< AiInt << endl;
|
||||
}/*
|
||||
(ZTypInt AiInt)*/
|
||||
_FFC_(ZCShowData1)
|
||||
|
||||
_FFS_(ZCShowData2)
|
||||
(ZTypInt AiInt, ZCTuple& AR_CTuple)
|
||||
{
|
||||
cout<<"# Elem2 : "<< AiInt << ", nth=" << AR_CTuple._1++ << endl;
|
||||
}/*
|
||||
(ZTypInt AiInt, ZCTuple& AR_CTuple)*/
|
||||
_FFC_(ZCShowData2)
|
||||
|
||||
_FFS_(ZCShowData3)
|
||||
(ZTypInt AiInt, ZCTuple* AP_CTuple)
|
||||
{
|
||||
cout<<"# Elem3 : "<< AiInt << ", nth=" << AP_CTuple->_1++ << endl;
|
||||
}/*
|
||||
(ZTypInt AiInt, ZCTuple* AR_CTuple)*/
|
||||
_FFC_(ZCShowData3)
|
||||
|
||||
_FFS_(ZCShowData4)
|
||||
(ZTypInt AiInt, ZCTuple* AP_CTuple)
|
||||
{
|
||||
cout<<"# Elem4 : "<< AiInt << ", nth=" << AP_CTuple->_1++ << endl;
|
||||
}/*
|
||||
(ZTypInt AiInt, ZCTuple* AP_CTuple)*/
|
||||
_FFC_(ZCShowData4)
|
||||
|
||||
_FFS_(ZCShowData5)
|
||||
(ZTypInt AiInt, int& AiIndex)
|
||||
{
|
||||
cout<<"# Elem5 : "<< AiInt << ", nth=" << AiIndex++ << endl;
|
||||
}/*
|
||||
(ZTypInt AiInt, int& AiIndex)*/
|
||||
_FFC_(ZCShowData5)
|
||||
|
||||
_FFS_(ZCShowData6)
|
||||
(ZTypInt AiInt, int& AiIndex)
|
||||
{
|
||||
cout<<"# Elem6 : "<< AiInt << ", nth=" << AiIndex++ << endl;
|
||||
}/*
|
||||
(ZTypInt AiInt, int& AiIndex)*/
|
||||
_FFC_(ZCShowData6)
|
||||
|
||||
|
||||
ZNsHide::ZCFunctor1 VO_CFunctor1;
|
||||
/* ZCFunctor1 선언이 main() 바깥에 있어야 하는 문제를 해결할 수 없을까. */
|
||||
|
||||
VO_IntList.IterElement(ZCShowData1::Exec);
|
||||
VO_IntList.IterElemRef(ZCShowData2::Exec, VO_CTuple ); VO_CTuple._1=1 ;
|
||||
VO_IntList.IterElement(ZCShowData3::Exec, &VO_CTuple);
|
||||
VO_IntList.IterElement(&VO_CFunctor1 );
|
||||
VO_IntArr .IterElement(&VO_CFunctor1 ); VO_CTuple._1=1 ;
|
||||
VO_IntArr .IterElement(ZCShowData4::Exec, &VO_CTuple); VO_CTuple._1=1 ;
|
||||
VO_IntArr .IterElement(ZCShowData5::Exec, ZNsMain::ZtCRef<int>(VO_CTuple._1));
|
||||
VO_IntList.IterElement(ZCShowData5::Exec, ZNsMain::ZtCRef<int>(VO_CTuple._1));
|
||||
|
||||
cout<< "# Press Any Key to exit" << endl; cin.get();
|
||||
|
||||
return 0;
|
||||
}/*
|
||||
int main(int ArgiCnt, char** AppArgu)*/
|
||||
|
||||
|
||||
/*/////////////////////////////////////
|
||||
|
||||
|
||||
■ 컴파일
|
||||
|
||||
g++ -o test.exe test.cpp -I..
|
||||
|
||||
|
||||
/////////////////////////////////////*/
|
Reference in New Issue
Block a user