Compare commits

...

108 Commits

Author SHA1 Message Date
/* User with id == 0 is a fake user from git author */ sauron
b1702c58d4 commit 2025-08-21 14:12 edit a bit in ZMainHead.H 2025-08-21 14:33:10 +09:00
/* User with id == 0 is a fake user from git author */ sauron
8da631d2f4 commit 2025-08-21 14:06 ATOI => AtoI, ATOL => AtoL etc in ZMainHead.H and ZtCStringEx.H 2025-08-21 14:32:45 +09:00
/* User with id == 0 is a fake user from git author */ sauron
0610328f2f commit 2025-08-21 13:57 edit a bit ZMainHead.H 2025-08-21 13:57:12 +09:00
/* User with id == 0 is a fake user from git author */ sauron
9d407559ca commit 2025-08-21 12:44 edit a bit ZtCArray 2025-08-21 12:44:34 +09:00
/* User with id == 0 is a fake user from git author */ sauron
4386372bf0 commit 2025-08-21 12:18 edit a bit ZtCStringBase 2025-08-21 12:18:21 +09:00
/* User with id == 0 is a fake user from git author */ sauron
c41d530053 commit 2025-08-21 12:12 edit a bit ZtCStringBase 2025-08-21 12:12:13 +09:00
/* User with id == 0 is a fake user from git author */ sauron
6f56e4fcff commit 2025-08-21 09:36 edit a bit ZtCStringBase 2025-08-21 09:36:16 +09:00
/* User with id == 0 is a fake user from git author */ sauron
16dcc5199a commit 2025-08-21 00:59 edit a bit ZtCStringBase 2025-08-21 00:59:39 +09:00
/* User with id == 0 is a fake user from git author */ sauron
21f026c1fe commit 2025-08-21 00:30 edit a bit ZtCStringBase 2025-08-21 00:30:27 +09:00
/* User with id == 0 is a fake user from git author */ sauron
c734e73690 commit 2025-08-20 17:52 edit a bit ZtCStringBase 2025-08-20 17:52:45 +09:00
/* User with id == 0 is a fake user from git author */ sauron
8c88ac81ac commit 2025-08-20 17:38 edit a bit ZtCStringBase 2025-08-20 17:39:02 +09:00
/* User with id == 0 is a fake user from git author */ sauron
b20a1083a5 commit 2025-08-20 17:30 edit a bit ZtCStringBase 2025-08-20 17:30:10 +09:00
/* User with id == 0 is a fake user from git author */ sauron
549aea421d commit 2025-08-20 17:16 edit a bit ZtCStringBase 2025-08-20 17:16:59 +09:00
/* User with id == 0 is a fake user from git author */ sauron
b83b4120fb commit 2025-08-20 15:04 edit a bit ZtCStringBase 2025-08-20 15:04:04 +09:00
/* User with id == 0 is a fake user from git author */ sauron
e554fd25f3 commit 2025-08-20 14:46 add GeLenght() in ZtCStringBase 2025-08-20 14:46:30 +09:00
/* User with id == 0 is a fake user from git author */ sauron
15a37c761e commit 2025-08-20 12:32 delete __Init() and __Fini() 2025-08-20 12:33:05 +09:00
/* User with id == 0 is a fake user from git author */ sauron
fbc3bf0093 commit 2025-08-20 11:57 __FastMoveObj => ZftMoveFast 2025-08-20 11:57:40 +09:00
/* User with id == 0 is a fake user from git author */ sauron
af4b3c9e98 commit 2025-08-20 09:31 edit a bit ZCppMain/ZMainHead.H 2025-08-20 09:31:05 +09:00
/* User with id == 0 is a fake user from git author */ sauron
8293789af0 commit 2025-08-20 08:47 edit ZtCMoveObj a bit in ZCppMain/ZMainHead.H 2025-08-20 08:47:38 +09:00
/* User with id == 0 is a fake user from git author */ sauron
1a85ff753d commit 2025-08-19 23:01 edit ZtCMoveObj in ZCppMain/ZMainHead.H 2025-08-19 23:01:50 +09:00
/* User with id == 0 is a fake user from git author */ sauron
a9032f80a7 commit 2025-08-19 21:31 edit __FastMoveObj() in ZCppMain/ZtCStringEx.H 2025-08-19 22:21:02 +09:00
/* User with id == 0 is a fake user from git author */ sauron
a130866f33 commit 2025-08-19 21:31 edit a bit ZCppMain/ZtCStringEx.H 2025-08-19 21:31:41 +09:00
/* User with id == 0 is a fake user from git author */ sauron
4a076cb1d8 commit 2025-08-19 21:19 edit a bit ZCppMain/ZtCStringEx.H 2025-08-19 21:19:09 +09:00
/* User with id == 0 is a fake user from git author */ sauron
e8cf6460cb commit 2025-08-19 21:03 edit a bit ZCppMain/ZtCStringEx.H 2025-08-19 21:03:39 +09:00
/* User with id == 0 is a fake user from git author */ sauron
7a36c47bae commit 2025-08-19 19:58 edit a bit ZCppMain/ZtCMainChars.H 2025-08-19 19:58:14 +09:00
/* User with id == 0 is a fake user from git author */ sauron
fd7f0f4989 commit 2025-08-19 16:41 edit a bit ZCppMain/ZtCMainChars.H 2025-08-19 16:41:33 +09:00
/* User with id == 0 is a fake user from git author */ sauron
15ba79c33c commit 2025-08-19 14:15 edit a bit ZCppMain/ZtCMainChars.H 2025-08-19 14:15:42 +09:00
/* User with id == 0 is a fake user from git author */ sauron
1a4120ed22 commit 2025-08-19 01:32 edit a bit ZCppMain/ZtCSortObjList.H 2025-08-19 01:32:53 +09:00
/* User with id == 0 is a fake user from git author */ sauron
98712ea047 commit 2025-08-19 01:25 __CSIMLIST_H__ to __ZCPPMAIN__ZCSIMLIST_H__ : ZCppMain/ZtCSimList.H 2025-08-19 01:25:37 +09:00
/* User with id == 0 is a fake user from git author */ sauron
279179e999 commit 2025-08-19 01:23 utf8 convert ZCppMain/ZtCSimList.H 2025-08-19 01:23:41 +09:00
/* User with id == 0 is a fake user from git author */ sauron
e6b7cea027 commit 2025-08-19 01:17 add ZCppMain/ZtCSimList.H 2025-08-19 01:17:45 +09:00
/* User with id == 0 is a fake user from git author */ sauron
89db873862 commit 2025-08-18 17:26 edit ZCppMain/ZtCObjAVL.H : add ZtCExamAVl 2025-08-18 17:26:47 +09:00
/* User with id == 0 is a fake user from git author */ sauron
c1d647b8e2 commit 2025-08-18 17:11 edit ZCppMain/ZtCArray.H : add ZtCExamArray 2025-08-18 17:12:13 +09:00
/* User with id == 0 is a fake user from git author */ sauron
b48034a42f commit 2025-08-18 02:03 edit ZCppMain/ZtCLoadDataBlock.H : ZCLoadDataBlock1/2 => ZCExamLoadBlock1/2 2025-08-18 02:58:51 +09:00
/* User with id == 0 is a fake user from git author */ sauron
a4c6342573 commit 2025-08-18 00:18 edit ZCppMain/ZtCObjList.H : add ZtCExamObjList 2025-08-18 00:29:37 +09:00
/* User with id == 0 is a fake user from git author */ sauron
af60e817f3 commit 2025-08-17 16:01 edit ZCppMain/ZtCStringEx.H : correct double TypeLength typedef 2025-08-17 16:01:36 +09:00
/* User with id == 0 is a fake user from git author */ sauron
a878376507 commit 2025-08-17 15:25 edit ZCppMain/ZtCSortObjList.H : add 'include ZCppMain/ZtCArray.H and ZCppMain/ZtCArray.H 2025-08-17 15:44:23 +09:00
/* User with id == 0 is a fake user from git author */ sauron
b56e7a66c0 commit 2025-08-17 15:25 edit ZCppMain/ZtCObjList.H : __ZCPPMAIIN__ZTCOBJLIST_H__ => __ZCPPMAIN__ZTCOBJLIST_H__ 2025-08-17 15:32:44 +09:00
/* User with id == 0 is a fake user from git author */ sauron
69b2ed8018 commit 2025-08-17 15:25 edit ZCppMain/ZtCSortObjList.H : add ZNsExam::ZtCSortIntList 2025-08-17 15:26:37 +09:00
/* User with id == 0 is a fake user from git author */ sauron
1dd4a87e75 commit 2025-08-17 02:54 utf8 변환 : some files 2025-08-17 02:54:18 +09:00
/* User with id == 0 is a fake user from git author */ sauron
95527d0544 commit 2025-08-17 02:51 utf8 변환 : ZCppMain/ZtCSortObjList.H 2025-08-17 02:51:48 +09:00
/* User with id == 0 is a fake user from git author */ sauron
d67337476f commit 2025-08-17 02:47 is coding ZCppMain/ZtCSortObjList.H 시험이 필요 2025-08-17 02:48:15 +09:00
/* User with id == 0 is a fake user from git author */ sauron
56fe854723 commit 2025-08-16 34:34 edit ZCppMain/ZtCLoadDataBlock.H
ZCLoadDataBlock1 과 ZCLoadDataBlock2 의 소속을 ZNsExam 에서 ZNsExam::ZtCDummy 로 옮김
2025-08-17 01:06:21 +09:00
/* User with id == 0 is a fake user from git author */ sauron
f7636ecc5d commit 2025-08-16 34:34
git add ZCppMain/ZMainHead.H
git add ZCppMain/ZtCArray.H
git add ZCppMain/ZtCObjList.H
git add ZCppMain/ZMainAVL.H
git add ZCppMain/ZMainHeadEx.H
git add ZCppMain/ZMainXhtml.H
git add ZCppMain/ZtCLoadDataBlock.H
git add ZCppMain/ZtCMainChars.H
git add ZCppMain/ZtCObjAVL.H
git add ZCppMain/ZtCStringEx.H
git add ZCppMain/ZtCTreeData.H
2025-08-16 23:35:44 +09:00
/* User with id == 0 is a fake user from git author */ sauron
d61bf88525 edit ZMainHead.H 2021-03-25 16:51:46 +09:00
/* User with id == 0 is a fake user from git author */ sauron
e56139cbf1 edit ZMainHead.H 2021-03-25 16:50:23 +09:00
/* User with id == 0 is a fake user from git author */ sauron
2fc5fe33db edit ZMainHead.H 2021-03-25 16:41:48 +09:00
/* User with id == 0 is a fake user from git author */ sauron
a3458a47e9 edit ZMainHead.H 2021-03-25 16:05:16 +09:00
/* User with id == 0 is a fake user from git author */ sauron
c73bcedb1b edit ZMainHead.H etc 2021-03-24 10:37:45 +09:00
/* User with id == 0 is a fake user from git author */ sauron
2b2e17494f edit test.cpp 2021-03-11 11:09:15 +09:00
/* User with id == 0 is a fake user from git author */ sauron
273a3f0c77 edit test.cpp 2021-03-11 11:04:38 +09:00
/* User with id == 0 is a fake user from git author */ sauron
a2b499a7b4 edit test.cpp 2021-03-10 17:27:57 +09:00
/* User with id == 0 is a fake user from git author */ sauron
f8fbc66cee edit test.cpp 2021-03-10 16:17:47 +09:00
/* User with id == 0 is a fake user from git author */ sauron
f74469a01c edit test.cpp 2021-03-10 13:03:09 +09:00
/* User with id == 0 is a fake user from git author */ sauron
f2b9005d64 edit test.cpp 2021-03-10 11:28:37 +09:00
/* User with id == 0 is a fake user from git author */ sauron
bda29ec4b3 edit test.cpp 2021-03-09 16:51:51 +09:00
/* User with id == 0 is a fake user from git author */ sauron
effb5f0200 edit test.cpp 2021-03-09 16:38:34 +09:00
/* User with id == 0 is a fake user from git author */ sauron
51f46a76da edit test.cpp 2021-03-09 16:33:27 +09:00
/* User with id == 0 is a fake user from git author */ sauron
23ffdebe25 edit test.cpp 2021-03-08 22:11:29 +09:00
/* User with id == 0 is a fake user from git author */ sauron
9ebd015454 edit test.cpp 2021-03-08 22:10:49 +09:00
/* User with id == 0 is a fake user from git author */ sauron
eebfc2db5e edit test.cpp 2021-03-08 22:09:33 +09:00
/* User with id == 0 is a fake user from git author */ sauron
b44c711708 edit test.cpp 2021-03-08 21:55:48 +09:00
/* User with id == 0 is a fake user from git author */ sauron
a6ba64d149 edit test.cpp 2021-03-08 20:41:16 +09:00
/* User with id == 0 is a fake user from git author */ sauron
7bb03e148d edit test.cpp 2021-03-08 20:37:34 +09:00
/* User with id == 0 is a fake user from git author */ sauron
2b4f3b5007 edit test.cpp 2021-03-08 20:29:43 +09:00
/* User with id == 0 is a fake user from git author */ sauron
8b2d370652 edit ZtCArray.H 2021-03-08 20:27:36 +09:00
/* User with id == 0 is a fake user from git author */ sauron
69bcf4846b edit ZtCObjList.H 2021-03-04 18:06:15 +09:00
/* User with id == 0 is a fake user from git author */ sauron
b6d69db347 add ZtCArray.H 2021-03-04 18:02:17 +09:00
/* User with id == 0 is a fake user from git author */ sauron
dc0ab7c173 add ZtCArray.H 2021-03-04 17:57:34 +09:00
/* User with id == 0 is a fake user from git author */ sauron
8b2a6e6d4e add ZtCArray.H 2021-03-04 17:55:37 +09:00
/* User with id == 0 is a fake user from git author */ sauron
43e518b16f edit ZMainHead.H 2021-03-04 17:04:16 +09:00
/* User with id == 0 is a fake user from git author */ sauron
a28897a739 edit ZMainHead.H 2021-03-04 16:28:39 +09:00
/* User with id == 0 is a fake user from git author */ sauron
e00d040a9d edit ZMainHead.H 2021-03-04 16:27:38 +09:00
/* User with id == 0 is a fake user from git author */ sauron
943473ef50 edit test.cpp 2021-03-04 16:22:15 +09:00
/* User with id == 0 is a fake user from git author */ sauron
46de31135c edit test.cpp 2021-03-04 16:21:22 +09:00
/* User with id == 0 is a fake user from git author */ sauron
104ce1f866 edit test.cpp 2021-03-04 16:20:05 +09:00
/* User with id == 0 is a fake user from git author */ sauron
c795e5c62e edit test.cpp 2021-03-04 16:19:02 +09:00
/* User with id == 0 is a fake user from git author */ sauron
3ed8a75620 edit test.cpp 2021-03-04 16:15:58 +09:00
/* User with id == 0 is a fake user from git author */ sauron
ff89c6a6ab edit test.cpp 2021-03-04 16:14:44 +09:00
/* User with id == 0 is a fake user from git author */ sauron
3b17e42092 edit test.cpp 2021-03-04 16:10:09 +09:00
/* User with id == 0 is a fake user from git author */ sauron
5f52208a3f edit ZMainHead.H 2021-03-04 15:49:03 +09:00
/* User with id == 0 is a fake user from git author */ sauron
0ef49bbc47 edit ZMainHead.H 2021-03-04 15:40:36 +09:00
/* User with id == 0 is a fake user from git author */ sauron
024c9d35db edit ZMainHead.H 2021-03-04 15:39:34 +09:00
/* User with id == 0 is a fake user from git author */ sauron
11f325e278 edit ZMainHead.H 2021-03-04 15:36:45 +09:00
/* User with id == 0 is a fake user from git author */ sauron
ccb9f7756b edit test.cpp a bit 2021-02-26 18:02:09 +09:00
/* User with id == 0 is a fake user from git author */ sauron
be00a2991e edit test.cpp a bit 2021-02-26 18:00:29 +09:00
/* User with id == 0 is a fake user from git author */ sauron
2facc77480 edit test.cpp a bit 2021-02-26 17:58:57 +09:00
/* User with id == 0 is a fake user from git author */ sauron
8b62a66e9d edit test.cpp a bit 2021-02-26 17:57:28 +09:00
/* User with id == 0 is a fake user from git author */ sauron
7217785e33 edit test.cpp a bit 2021-02-26 17:55:33 +09:00
/* User with id == 0 is a fake user from git author */ sauron
dd0541c5fa edit test.cpp a bit 2021-02-26 17:41:18 +09:00
/* User with id == 0 is a fake user from git author */ sauron
659daadeaf edit test.cpp a bit 2021-02-26 17:36:05 +09:00
/* User with id == 0 is a fake user from git author */ sauron
80adf8aeb7 edit test.cpp a bit 2021-02-26 17:35:36 +09:00
/* User with id == 0 is a fake user from git author */ sauron
7d83d10fed edit test a bit 2021-02-26 17:34:33 +09:00
/* User with id == 0 is a fake user from git author */ sauron
3f8ecaef67 edit test a bit 2021-02-26 17:33:59 +09:00
/* User with id == 0 is a fake user from git author */ sauron
8af9880d23 edit ZtCObjList.H a bit 2021-02-26 17:28:33 +09:00
/* User with id == 0 is a fake user from git author */ sauron
4c89ca0c06 edit ZtCObjList.H a bit 2021-02-26 17:26:58 +09:00
/* User with id == 0 is a fake user from git author */ sauron
75659d8dbe edit ZtCSortObjList.H a bit 2021-02-26 17:22:31 +09:00
/* User with id == 0 is a fake user from git author */ sauron
6dc1a28af4 add ZtCObjList.H 2021-02-26 17:21:25 +09:00
/* User with id == 0 is a fake user from git author */ sauron
5e7d0deffb edit ZMainHead.H a bit 2021-02-25 17:52:07 +09:00
/* User with id == 0 is a fake user from git author */ sauron
8fda9a017b edit ZMainHead.H a bit 2021-02-25 17:51:25 +09:00
/* User with id == 0 is a fake user from git author */ sauron
a433979bd7 edit ZMainHead.H a bit 2021-02-25 17:49:30 +09:00
/* User with id == 0 is a fake user from git author */ sauron
c8afa6d08a edit ZMainHead.H a bit 2021-02-25 17:47:58 +09:00
/* User with id == 0 is a fake user from git author */ sauron
639c5f8347 edit ZMainHead.H a bit 2021-02-25 17:45:17 +09:00
/* User with id == 0 is a fake user from git author */ sauron
822f54cc50 edit ZMainHead.H a bit 2021-02-25 17:42:32 +09:00
/* User with id == 0 is a fake user from git author */ sauron
9a3bff1103 edit ZMainHead.H 2021-02-25 17:34:50 +09:00
/* User with id == 0 is a fake user from git author */ sauron
48678083ab add test.cpp 2021-02-25 17:27:36 +09:00
/* User with id == 0 is a fake user from git author */ sauron
e067b495dc edit ZMainHead.H a bit 2021-02-25 17:11:44 +09:00
/* User with id == 0 is a fake user from git author */ sauron
bf00a06e24 add ZCppMain/ZMainHead.H 2021-02-25 16:23:13 +09:00
14 changed files with 41530 additions and 0 deletions

360
ZCppMain/ZMainAVL.H Normal file
View File

@ -0,0 +1,360 @@

#ifndef __ZCPPMAIN_ZMAINAVL_H__
#define __ZCPPMAIN_ZMAINAVL_H__
#include "ZCppMain/ZMainHead.H"
namespace ZNsMain
{
namespace ZNsEnum
{
enum ZEAVL_INSERT
{
ZEAVL_INSERT_RIGHT = +1,
ZEAVL_INSERT_OK = 0, /* 삽입 후의 평형계수가 0 이다. */
ZEAVL_INSERT_LEFT = -1,
ZEAVL_INSERT_NONE = -2 /* 삽입 안 됨 */
};/*
enum ZEAVL_INSERT*/
}/*
namespace ZNsEnum*/
namespace ZNsInterface
{
template<typename TypeArg> class ZtCAVL_BASE
{
protected:
template<typename TNode> void OnEqual(TypeArg AR_Data, TNode* AP_Node)
{
}/*
template<typename TNode> void OnEqual(TypeArg AR_Data, TNode* AP_Node) */
template<typename TKey, typename TNode> void OnEqualKey(TKey AR_Key, TNode* AP_Node)
{
}/*
template<typename TKey, typename TNode> void OnEqualKey(TKey AR_Key, TNode* AP_Node) */
protected:
};/*
template<typename TypeArg> class ZtCAVL_BASE*/
/*//////////////////////////////////////////////////////////////////////////
■ 아래 ZtCAVL_NodeBase<> 의 각 멤버 함수는 ZtCAVL_BASE<> 의 멤버 함수보다
인수가 하나 줄어든 것을 볼 수 있다. ZtCAVL_BASE<> 에서 같은 이름의 함수를
자연스럽게 호출할 수 있게 한 것이다. 따라서 ZtCAVL_BASE<> 의 멤버 함수에
서, AP_Node->OnEqual() 등으로 ZtCAVL_NodeBase<> 의 멤버 함수를 호출해 주
지 않으면, ZtCAVL_NodeBase<> 의 멤버는 어디에서도 호출되지 않는다. 왜 최초
에 이런 식으로 설계했을까. 한참 생각했는데, 아마 ZtCAVL_Multi_BASE<> 와
ZtCAVL_Multi_NodeBase<> 를 사용할려고 그랬을 것이다.
-- 2012-09-03 19:20:00
//////////////////////////////////////////////////////////////////////////*/
template<typename TNodeArg> class ZtCAVL_NodeBase
{
protected:
void OnEqual(TNodeArg AR_Data)
{
}/*
void OnEqual(TNodeArg AR_Data)*/
template<typename TKey> void OnEqualKey(TKey AR_Key)
{
}/*
template<typename TKey> void OnEqualKey(TKey AR_Key)*/
protected:
};/*
template<typename TNodeArg> class ZtCAVL_NodeBase*/
template<typename TypeArg> class ZtCAVL_Multi_BASE
{
protected:
template<typename TNode> void OnEqual(TypeArg AR_Data, TNode* AP_Node)
{
AP_Node->OnEqual(AR_Data);
}/*
template<typename TNode> void OnEqual(TypeArg AR_Data, TNode* AP_Node) */
template<typename TKey, typename TNode> void OnEqualKey(TKey AR_Key, TNode* AP_Node)
{
AP_Node->OnEqualKey(AR_Key);
}/*
template<typename TKey, typename TNode> void OnEqualKey(TKey AR_Key, TNode* AP_Node) */
protected:
};/*
template<typename TypeArg> class ZtCAVL_Multi_BASE*/
/*//////////////////////////////////////////////////////////////
■ ZtCAVL_Multi_NodeBase template 로 multi set/map 을 구성하는 경우,
ZtCAVL_Multi_NodeBase::TypeEqual 자료형에 접근하는 예.
class CTypeMy
{
public:
typedef CLargeAVL<some param> CLargeMap;
typedef typename CLargeMap::ZCNode::TypeEqual TypeEqual;
}
//////////////////////////////////////////////////////////////*/
template< typename TNodeArg, typename TEqualList
>
class ZtCAVL_Multi_NodeBase ////////////////////
{
public :
typedef TEqualList TypeEqual;
protected:
TEqualList mo_EqualList;
public :
void OnEqual(TNodeArg AR_Data)
{
mo_EqualList.push_back(AR_Data);
}/*
void OnEqual(TNodeArg AR_Data)*/
template<typename TKey> void OnEqualKey(TKey AR_Key)
{
mo_EqualList.push_back(AR_Key);
}/*
template<typename TKey> void OnEqualKey(TKey AR_Key) */
const TEqualList& GetCEqualList() const
{
return mo_EqualList;
}/*
const TEqualList& GetCEqualList() const*/
public:
};/*
template< typename TNodeArg, typename TEqualList
>
class ZtCAVL_Multi_NodeBase //////////////////*/
/*/////////////////////////////////////////////////////////////////////
■ AVL 트리의 데이타 타입이 포인터인 경우, 포인터를 정수처럼 다루어서
비교 연산자를 정의하는 클래스 템플릿이다.
/////////////////////////////////////////////////////////////////////*/
template<typename TData> class ZtCAVL_PtrLongData
{
public :
typedef TData* TypeData;
protected:
TData* mp_CData;
public :
ZtCAVL_PtrLongData()
{
mp_CData=0;
}/*
ZtCAVL_PtrLongData()*/
TData* GetDataPtr() const
{
return mp_CData;
}/*
TData* GetDataPtr() const*/
void SetDataPtr(TData* AP_CData)
{
mp_CData=AP_CData;
}/*
void SetDataPtr(TData* AP_CData)*/
operator ZNsMain::ZTypIntPtr() const
{
return mp_CData;
}/*
operator ZNsMain::ZTypIntPtr() const*/
ZtCAVL_PtrLongData& operator=(const ZtCAVL_PtrLongData& rhs)
{
mp_CData=rhs.mp_CData; return *this;
}/*
ZtCAVL_PtrLongData& operator=(const ZtCAVL_PtrLongData& rhs)*/
ZtCAVL_PtrLongData& operator=(const TData* AP_CData)
{
mp_CData=const_cast<TData*>(AP_CData); return *this;
}/*
ZtCAVL_PtrLongData& operator=(const TData* AP_CData)*/
bool operator==(const ZtCAVL_PtrLongData& rhs) const{return mp_CData==rhs.mp_CData;}
bool operator> (const ZtCAVL_PtrLongData& rhs) const{return (ZNsMain::ZTypIntPtr)mp_CData > (ZNsMain::ZTypIntPtr)rhs.mp_CData;}
bool operator< (const ZtCAVL_PtrLongData& rhs) const{return (ZNsMain::ZTypIntPtr)mp_CData < (ZNsMain::ZTypIntPtr)rhs.mp_CData;}
bool operator==(const TData* AP_CData) const{return mp_CData==AP_CData;}
bool operator> (const TData* AP_CData) const{return (ZNsMain::ZTypIntPtr)mp_CData > (ZNsMain::ZTypIntPtr)AP_CData;}
bool operator< (const TData* AP_CData) const{return (ZNsMain::ZTypIntPtr)mp_CData < (ZNsMain::ZTypIntPtr)AP_CData;}
protected:
};/*
template<typename TData> class ZtCAVL_PtrLongData*/
/* int, long 같이 비교연산이 가능한 primitive 타입이나 object 를
key 로 가지고 있는 경우에, 해당 AVL 트리의 노드 데이타로 바로
쓸 수 있도록 wrap 한 클래스 템플릿 */
template< typename TKeyData ,
typename TMainData,
typename TKeyArg =const TKeyData &,
typename TMainArg=const TMainData&
>
class ZtCAVL_KeyData //////////////////////////
{
public :
typedef TKeyData TypeKey ;
typedef TMainData TypeData;
protected:
TKeyData mo_CKeyData ; mutable
TMainData mo_CMainData;
public :
ZtCAVL_KeyData(){}
ZtCAVL_KeyData(TKeyArg AO_TKeyArg)
{
mo_CKeyData=AO_TKeyArg;
}/*
ZtCAVL_KeyData(TKeyArg AO_TKeyArg)*/
ZtCAVL_KeyData(TKeyArg AO_TKeyArg, TMainArg AO_TMainArg)
{
mo_CKeyData =AO_TKeyArg ;
mo_CMainData=AO_TMainArg;
}/*
ZtCAVL_KeyData(TKeyArg AO_TKeyArg, TMainArg AO_TMainArg)*/
TKeyArg GetCKeyData () const{return mo_CKeyData ;}
TMainArg GetCMainData () const{return mo_CMainData;}
TMainData& GetCMainDataRef() const{return mo_CMainData;}
void SetCMainData(TMainArg AO_TRealArg) const
{
mo_CMainData=AO_TRealArg;
}/*
void SetCMainData(TMainArg AO_TRealArg) const*/
void SetKeyData(TKeyArg AO_TKeylArg)
{
mo_CKeyData=AO_TKeylArg;
}/*
void SetKeyData(TKeyArg AO_TKeylArg)*/
bool operator==(const ZtCAVL_KeyData& rhs) const{return mo_CKeyData==rhs.mo_CKeyData;}
bool operator> (const ZtCAVL_KeyData& rhs) const{return mo_CKeyData> rhs.mo_CKeyData;}
bool operator< (const ZtCAVL_KeyData& rhs) const{return mo_CKeyData< rhs.mo_CKeyData;}
bool operator==(TKeyArg AO_TPrimitive) const{return mo_CKeyData==AO_TPrimitive;}
bool operator> (TKeyArg AO_TPrimitive) const{return mo_CKeyData> AO_TPrimitive;}
bool operator< (TKeyArg AO_TPrimitive) const{return mo_CKeyData< AO_TPrimitive;}
ZtCAVL_KeyData& operator=(const ZtCAVL_KeyData& rhs)
{
if(this==&rhs) return *this;
mo_CKeyData =rhs.mo_CKeyData ;
mo_CMainData=rhs.mo_CMainData; return *this;
}/*
ZtCAVL_KeyData& operator=(const ZtCAVL_KeyData& rhs)*/
ZtCAVL_KeyData& operator=(TKeyArg AO_TPrimitive)
{
mo_CKeyData=AO_TPrimitive; return *this;
}/*
ZtCAVL_KeyData& operator=(TKeyArg AO_TPrimitive)*/
public:
};/*
template< typename TKeyData ,
typename TMainData,
typename TKeyArg =const TKeyData &,
typename TMainArg=const TMainData&
>
class ZtCAVL_KeyData ////////////////////////*/
}/*
namespace ZNsInterface*/
/*/////////////////////////////////////////////////////////////////////////////////////
■ mulit set 으로 활용하는 예제코드
ZNsMain::CLargeAVL ///////////////////////////////////
<
int,
int,
ZNsMain::ZNsInterface::ZtCAVL_Multi_BASE<int>,
ZNsMain::ZNsInterface::ZtCAVL_Multi_NodeBase<int, ZNsMain::ZtCDoubleList<int> >
>
VO_CLargeAvl_Multi; //////////////////////////////////
VO_CLargeAvl_Multi.AddData(1);
VO_CLargeAvl_Multi.AddData(2);
VO_CLargeAvl_Multi.AddData(2);
VO_CLargeAvl_Multi.AddData(2);
VO_CLargeAvl_Multi.AddData(2);
/////////////////////////////////////////////////////////////////////////////////////*/
namespace NsType
{
template< typename TStringData, //= ZNsMain::ZtCStringBase<char> ,
typename TEnvVar , //= ZNsMain::ZNsCGI::ZNsBase::ZtCEnvVar<TStringData>,
typename TEnvVarSet //= ZNsMain::ZtCObjAVL<TEnvVar>
>
class ZtCTypeEnvVarSet /*############################################################*/
{
public:
typedef TStringData ZCStringData;
typedef TEnvVar ZCEnvVar ;
typedef TEnvVarSet ZCEnvVarSet ;
typedef typename ZCEnvVarSet ::ZCNode ZCEnvVarNode;
typedef typename ZCStringData::ZCMainChars ZCMainChars ;
typedef typename ZCStringData::TypeChar TypeChar ;
typedef typename ZCStringData::TypeLength TypeLength ;
public:
};/*
template< typename TStringData, //= ZNsMain::ZtCStringBase<char> ,
typename TEnvVar , //= ZNsMain::ZNsCGI::ZNsBase::ZtCEnvVar<TStringData>,
typename TEnvVarSet //= NsCPP::ZtCObjAVL<TEnvVar>
>
class ZtCTypeEnvVarSet /*############################################################*/
}/*
namespace NsType*/
}/*
namespace ZNsMain */
#endif // __ZCPPMAIN_ZMAINAVL_H__

4377
ZCppMain/ZMainHead.H Normal file

File diff suppressed because it is too large Load Diff

7194
ZCppMain/ZMainHeadEx.H Normal file

File diff suppressed because it is too large Load Diff

38
ZCppMain/ZMainXhtml.H Normal file
View File

@ -0,0 +1,38 @@

#ifndef __ZCPPMAIIN__ZMAINXHTML_H__
#define __ZCPPMAIIN__ZMAINXHTML_H__
namespace ZNsMain
{
template<typename TStringData> TStringData& ZftConvertXhtml(TStringData& ARR_CString)
{
/* 데이타를 그대로 클라이언트에 전송하면
HTML 태그와 혼동될 수 있는데 이를 방지하기 위해
적절히 인코딩한다.
*/
return ARR_CString.
Replace("&" ,"&amp;" ). Replace("<" ,"&lt;" ).
Replace(">" ,"&gt;" ). Replace(" " ,"&nbsp;" ).
Replace("\n","<br />" );
}/*
template<typename TStringData> static TStringData& ConvertXhtml(TStringData& ARR_CString) */
template<typename TStringData> TStringData& ZftConvertXhtmlAtt(TStringData& ARR_CString)
{
// X(H)TML 의 속성에 올 수 있는 값으로 인코딩한다.
return ARR_CString.
Replace("&" ,"&amp;" ). Replace("<" ,"&lt;" ).
Replace(">" ,"&gt;" ). Replace("\"","&quot;" ).
Replace("\r","&#xA;" ). Replace("\n","&#xD;" );
}/*
template<typename TStringData> TStringData& ZftConvertXhtmlAtt(TStringData& ARR_CString) */
}/*
namespace ZNsMain*/
#endif // __ZCPPMAIIN__ZMAINXHTML_H__

1313
ZCppMain/ZtCArray.H Normal file

File diff suppressed because it is too large Load Diff

1865
ZCppMain/ZtCLoadDataBlock.H Normal file

File diff suppressed because it is too large Load Diff

7454
ZCppMain/ZtCMainChars.H Normal file

File diff suppressed because it is too large Load Diff

2526
ZCppMain/ZtCObjAVL.H Normal file

File diff suppressed because it is too large Load Diff

3656
ZCppMain/ZtCObjList.H Normal file

File diff suppressed because it is too large Load Diff

2327
ZCppMain/ZtCSimList.H Normal file

File diff suppressed because it is too large Load Diff

850
ZCppMain/ZtCSortObjList.H Normal file
View File

@ -0,0 +1,850 @@

#ifndef __ZCPPMAIN__ZCSORT_LIST_H__
#define __ZCPPMAIN__ZCSORT_LIST_H__
/*////////////////////////////////////////////////////
■ CDoublieList.H 와 CObjList.H 가 include 한다.
-- 2013-04-30 22:57:00
ZtCArray.H 와 ZtCObjList.H 가 include 한다.
-- 2025-08-17 14:37:00
현재는 ZtCArray.H 와 ZtCObjList.H 를 include 한다.
-- 2025-08-17 15:42:00
////////////////////////////////////////////////////*/
#include "ZCppMain/ZtCArray.H"
#include "ZCppMain/ZtCObjList.H"
namespace ZNsMain
{
// 양방향 연결리스트에 대한 정렬 클래스이다.
template<typename TTypObjList> class ZtCSortObjList
{
public :
typedef typename TTypObjList::ZCLink ZCLink ;
typedef typename TTypObjList::TypeData TypeData;
typedef typename TTypObjList::TypeArg TypeArg ;
typedef typename TTypObjList::TypeSize TypeSize;
private:
static inline bool IsMore(TypeArg AR_LeftType, TypeArg AR_RightType)
{
/* IsMore() 함수와 IsLess() 는 QuickSort() 멤버 함수에서 쓰는
함수 포인터에 대입하기 위해서 정의하였다. */
return AR_LeftType > AR_RightType ;
}/*
static inline bool IsMore(TypeArg AR_LeftType, TypeArg AR_RightType)*/
static inline bool IsLess(TypeArg AR_LeftType, TypeArg AR_RightType)
{
return AR_LeftType < AR_RightType ;
}/*
static inline bool IsLess(TypeArg AR_LeftType, TypeArg AR_RightType)*/
static inline void SwapLinkPtr(ZCLink*& APR_LinkI, ZCLink*& APR_LinkJ)
{
ZCLink* VP_Temp=APR_LinkI; APR_LinkI=APR_LinkJ; APR_LinkJ=VP_Temp;
}/*
static inline void SwapLinkPtr( ZCLink*& APR_LinkI, ZCLink*& APR_LinkJ) */
template
<typename TTypFuncIsMore, typename TTypFuncIsLess>
static void QuickSort
(
TTypFuncIsMore APF_IsMore ,
TTypFuncIsLess APF_IsLess ,
ZCLink* APA_LinkPtrArr[],
TypeSize AL_FirstIndex ,
TypeSize AL_LastIndex
)
/*##################################################*/
{
if(AL_FirstIndex<AL_LastIndex)
{
TypeSize i=AL_FirstIndex ;
TypeSize j=AL_LastIndex+1 ;
ZCLink* VP_PivotLinkPtr=APA_LinkPtrArr[i];
do //////
{
while(AL_LastIndex >i && APF_IsLess(APA_LinkPtrArr[++i]->GetData(), VP_PivotLinkPtr->GetData()));
while(AL_FirstIndex<j && APF_IsMore(APA_LinkPtrArr[--j]->GetData(), VP_PivotLinkPtr->GetData()));
if(i<j) SwapLinkPtr(APA_LinkPtrArr[i], APA_LinkPtrArr[j]);
}
while(i<j);
/* SwapLinkPtr(APA_LinkPtrArr[AL_FirstIndex], APA_LinkPtrArr[j]);
위 코드 보다 아래처럼 2 줄로 쓰는게 별도의 스택 변수를 사용하지
않아서 좋다.
*/
APA_LinkPtrArr[AL_FirstIndex]=APA_LinkPtrArr[j];
APA_LinkPtrArr[j ]=VP_PivotLinkPtr ;
QuickSort(APF_IsMore, APF_IsLess, APA_LinkPtrArr, AL_FirstIndex, j-1 );
QuickSort(APF_IsMore, APF_IsLess, APA_LinkPtrArr, j+1, AL_LastIndex);
}/*
if(AL_FirstIndex<AL_LastIndex)*/
}/*
template
<typename TTypFuncIsMore, typename TTypFuncIsLess>
static void QuickSort
(
TTypFuncIsMore APF_IsMore ,
TTypFuncIsLess APF_IsLess ,
ZCLink* APA_LinkPtrArr[],
TypeSize AL_FirstIndex ,
TypeSize AL_LastIndex
)
###########################################################*/
static void QuickSortAsc
(
ZCLink* APA_LinkPtrArr[], TypeSize AL_FirstIndex, TypeSize AL_LastIndex
)
/*####################*/
{
if(AL_FirstIndex<AL_LastIndex)
{
TypeSize i=AL_FirstIndex ;
TypeSize j=AL_LastIndex+1 ;
ZCLink* VP_PivotLinkPtr=APA_LinkPtrArr[i];
do ////
{
while(AL_LastIndex >i && APA_LinkPtrArr[++i]->GetData() < VP_PivotLinkPtr->GetData());
while(AL_FirstIndex<j && APA_LinkPtrArr[--j]->GetData() > VP_PivotLinkPtr->GetData());
if(i<j) SwapLinkPtr(APA_LinkPtrArr[i], APA_LinkPtrArr[j]);
}
while(i<j);
/* SwapLinkPtr(APA_LinkPtrArr[AL_FirstIndex], APA_LinkPtrArr[j]);
위 코드 보다 아래처럼 2 줄로 쓰는게 별도의 스택 변수를 사용하지 않아서 좋다.*/
APA_LinkPtrArr[AL_FirstIndex]=APA_LinkPtrArr[j];
APA_LinkPtrArr[j ]=VP_PivotLinkPtr ;
QuickSortAsc(APA_LinkPtrArr, AL_FirstIndex, j-1 );
QuickSortAsc(APA_LinkPtrArr, j+1, AL_LastIndex);
}/*
if(AL_FirstIndex<AL_LastIndex)*/
}/*
static void QuickSortAsc
(
ZCLink* APA_LinkPtrArr[], TypeSize AL_FirstIndex, TypeSize AL_LastIndex
)
/*####################*/
static void QuickSortDesc
(
ZCLink* APA_LinkPtrArr[], TypeSize AL_FirstIndex, TypeSize AL_LastIndex
)
/*#####################*/
{
if(AL_FirstIndex<AL_LastIndex)
{
TypeSize i=AL_FirstIndex ;
TypeSize j=AL_LastIndex+1;
ZCLink* VP_PivotLinkPtr=APA_LinkPtrArr[i];
do //////
{
while(AL_LastIndex >i && APA_LinkPtrArr[++i]->GetData() > VP_PivotLinkPtr->GetData());
while(AL_FirstIndex<j && APA_LinkPtrArr[--j]->GetData() < VP_PivotLinkPtr->GetData());
if(i<j) SwapLinkPtr(APA_LinkPtrArr[i], APA_LinkPtrArr[j]);
}
while(i<j);
/* SwapLinkPtr(APA_LinkPtrArr[AL_FirstIndex], APA_LinkPtrArr[j]);
위 코드 보다 아래처럼 2 줄로 쓰는게 별도의 스택 변수를 사용하지
않아서 좋다.
*/
APA_LinkPtrArr[AL_FirstIndex]=APA_LinkPtrArr[j];
APA_LinkPtrArr[j ]=VP_PivotLinkPtr ;
QuickSortDesc(APA_LinkPtrArr, AL_FirstIndex, j-1);
QuickSortDesc(APA_LinkPtrArr, j+1, AL_LastIndex);
}/*
if(AL_FirstIndex<AL_LastIndex)*/
}/*
static void QuickSortDesc
(
ZCLink* APA_LinkPtrArr[], TypeSize AL_FirstIndex, TypeSize AL_LastIndex
)
/*#####################*/
/*private:*/
public :
static void QuickSort(TTypObjList& ARR_CObjList, bool AB_IsAscending=true)
{
if(ARR_CObjList.GetSize()<=1) return;
TypeSize VL_SortSize = ARR_CObjList.GetSize() ;
ZCLink** VPP_LinkPtrArr = new ZCLink*[VL_SortSize];
if(VPP_LinkPtrArr==0)
{
// Add codes for memory over
return;
}/*
if(VPP_LinkPtrArr==0)*/
ZCLink* VP_TempLink =
ARR_CObjList.GetHeadLinkPtr();
TypeSize i=0 ;
for(; i<VL_SortSize; ++i)
{
VPP_LinkPtrArr[i] =VP_TempLink;
VP_TempLink =VP_TempLink->GetNextPtr();
}/*
for(; i<VL_SortSize; ++i)*/
if(AB_IsAscending==true)
QuickSortAsc (VPP_LinkPtrArr, 0, VL_SortSize-1);
else QuickSortDesc(VPP_LinkPtrArr, 0, VL_SortSize-1);
for(i=1; i<VL_SortSize; ++i) // VL_SortSize-1 번 순환
{
ZCLink::JoinLink(VPP_LinkPtrArr[i-1], VPP_LinkPtrArr[i]);
}/*
//////////////////////////*/
ZCLink::MakeCircle
(VPP_LinkPtrArr[0], VPP_LinkPtrArr[VL_SortSize-1]);
ARR_CObjList.mp_HeadLink = VPP_LinkPtrArr[0];
delete[] VPP_LinkPtrArr; ////////////////////
}/*
static void QuickSort(TTypObjList& ARR_CObjList, bool AB_IsAscending=true)*/
template
<typename TTypFuncIsMore, typename TTypFuncIsLess>
static void QuickSort
(
TTypObjList& ARR_CObjList ,
TTypFuncIsMore APF_IsMore ,
TTypFuncIsLess APF_IsLess
)
//////////////////////////////////////////////////////
{
if(ARR_CObjList.GetSize()<=1) return;
TypeSize VL_SortSize = ARR_CObjList.GetSize() ;
ZCLink** VPP_LinkPtrArr= new ZCLink*[VL_SortSize];
if(VPP_LinkPtrArr==0)
{
// Add codes for memory over
return;
}/*
if(VPP_LinkPtrArr==0)*/
ZCLink* VP_TempLink =
ARR_CObjList.GetHeadLinkPtr();
TypeSize i=0 ;
for(; i<VL_SortSize; ++i)
{
VPP_LinkPtrArr[i]=VP_TempLink;
VP_TempLink =VP_TempLink->GetNextPtr();
}/*
///////////////////////*/
QuickSort
(APF_IsMore, APF_IsLess, VPP_LinkPtrArr, 0, VL_SortSize-1);
for(i=1; i<VL_SortSize; ++i) // VL_SortSize-1 번 순환
{
ZCLink::JoinLink(VPP_LinkPtrArr[i-1], VPP_LinkPtrArr[i]);
}/*
//////////////////////////*/
ZCLink::MakeCircle
(VPP_LinkPtrArr[0], VPP_LinkPtrArr[VL_SortSize-1]);
ARR_CObjList.mp_HeadLink = VPP_LinkPtrArr[0];
delete[] VPP_LinkPtrArr; ////////////////////
}/*
template
<typename TTypFuncIsMore, typename TTypFuncIsLess>
static void QuickSort
(
TTypObjList& ARR_CObjList ,
TTypFuncIsMore APF_IsMore ,
TTypFuncIsLess APF_IsLess
)
////////////////////////////////////////////////////*/
static void QuickSortPart /*########################*/
(
TTypObjList& ARR_CObjList,
ZCLink* AP_HeadLink ,
TypeSize AL_HeadPos ,
ZCLink* AP_TailLink ,
TypeSize AL_TailPos ,
bool AB_IsAscending=true
)
/*##################################################*/
{
// AP_HeadLink 부터 AP_TailLink 까지만 정렬
#ifdef _DEBUG
if(ARR_CObjList.IsEmpty()==true || ARR_CObjList.Find(AP_HeadLink)!=AL_HeadPos || ARR_CObjList.Find(AP_TailLink)!=AL_TailPos || AL_HeadPos>AL_TailPos)
{
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 static void QuickSortPart("<<endl
<<" TTypObjList& ARR_CObjList,"<<endl
<<" ZCLink* AP_HeadLink ,"<<endl
<<" TypeSize AL_HeadPos ,"<<endl
<<" ZCLink* AP_TailLink ,"<<endl
<<" TypeSize AL_TailPos ,"<<endl
<<" bool AB_IsAscending=true )"<<endl
<<"Parameters are not valid"<<endl;
fileout.close();
exit(1);
}/*
if(ARR_CObjList.IsEmpty()==true || ARR_CObjList.Find(AP_HeadLink)!=AL_HeadPos || ARR_CObjList.Find(AP_TailLink)!=AL_TailPos || AL_HeadPos>AL_TailPos)*/
#endif //_DEBUG
if(AL_HeadPos==1 && AL_TailPos==ARR_CObjList.GetSize())
{
QuickSort(ARR_CObjList, AB_IsAscending); return;
}/*
if(AL_HeadPos==1 && AL_TailPos==ARR_CObjList.GetSize())*/
ZCLink* VP_PrevHead=AP_HeadLink->GetPrevPtr();
ZCLink* VP_NextTail=AP_TailLink->GetNextPtr();
TypeSize VL_SortSize=AL_TailPos-AL_HeadPos+1 ;
ZCLink** VPP_LinkPtrArr = new ZCLink*[VL_SortSize];
if(VPP_LinkPtrArr==0)
{
// Add codes for memory over
return;
}/*
if(VPP_LinkPtrArr==0)*/
ZCLink* VP_TempLink = AP_HeadLink; TypeSize i=0;
for(; i<VL_SortSize; ++i)
{
VPP_LinkPtrArr[i]=VP_TempLink;
VP_TempLink =VP_TempLink->GetNextPtr();
}/*
///////////////////////*/
if(AB_IsAscending==true)
QuickSortAsc (VPP_LinkPtrArr, 0, VL_SortSize-1);
else QuickSortDesc(VPP_LinkPtrArr, 0, VL_SortSize-1);
for(i=1; i<VL_SortSize; ++i) // VL_SortSize-1 번 순환
{
ZCLink::JoinLink(VPP_LinkPtrArr[i-1], VPP_LinkPtrArr[i]);
}/*
//////////////////////////*/
ZCLink::JoinLink(VP_PrevHead /*##########*/ , VPP_LinkPtrArr[0]);
ZCLink::JoinLink(VPP_LinkPtrArr[VL_SortSize-1], VP_NextTail );
if(AL_HeadPos==1)
ARR_CObjList.mp_HeadLink=VPP_LinkPtrArr[0];
delete[] VPP_LinkPtrArr; //////////////////////
}/*
static void QuickSortPart ############################
(
TTypObjList& ARR_CObjList,
ZCLink* AP_HeadLink ,
TypeSize AL_HeadPos ,
ZCLink* AP_TailLink ,
TypeSize AL_TailPos ,
bool AB_IsAscending=true
)
/*##################################################*/
static void MergeSort
(TTypObjList& ARR_AddList, TTypObjList& ARR_CutList, bool AB_IsAscending=true)
/*#################*/
{
/*/////////////////////////////////////////////////////////////////////////////
■ 연결리스트 ARR_AddList 와 ARR_CutList 는 이미 정렬되어 있는 것으로 간주하여
병합 정렬을 실시한다. ARR_CutList 의 앞 링크부터 차례로 끊어 ARR_AddList 의
적당한 링크에 삽입한다. 이 병합 정렬은 ARR_AddList 가 오름차순으로 정렬되어
있다면 ARR_CutList 도 오름차순으로 정렬되어 있어야 하고, AB_IsAscending 도
true 여야 원하는 결과를 얻을 수 있다.
/////////////////////////////////////////////////////////////////////////////*/
if( &ARR_AddList==&ARR_CutList ||
ARR_AddList.mp_HeadLink==0 ||
ARR_CutList.mp_HeadLink==0 ) return ;
/* 먼저 각 리스크를 삭제하는 신호를 보낸다. 진짜로 삭제하는 것은 아니지만,
링크를 이동시키는 과정에서 발생할 수 있는 에러를 막는데는 도움이 된다. */
ARR_AddList.OnDelete( ARR_AddList.mp_HeadLink, 1,
ARR_AddList.mp_HeadLink->mp_PrevLink, ARR_AddList.ml_Size );
ARR_CutList.OnDelete( ARR_CutList.mp_HeadLink, 1,
ARR_CutList.mp_HeadLink->mp_PrevLink, ARR_CutList.ml_Size );
bool (*pf_IsTrueValue)(TypeArg AR_Left,TypeArg rRigh);
if(AB_IsAscending==true)
pf_IsTrueValue=IsMore;
else pf_IsTrueValue=IsLess;
if(pf_IsTrueValue(ARR_AddList.GetTailData(), ARR_CutList.GetHeadData())==false)
{
ARR_AddList.JoinTail(ARR_CutList); return; // 이때는 더 이상 비교할 필요가 없다.
}/*
if(pf_IsTrueValue(ARR_AddList.GetTailData(), ARR_CutList.GetHeadData())==false)*/
ZCLink* VP_LhsTail =ARR_AddList.mp_HeadLink->mp_PrevLink;
ZCLink* VP_LhsTemp =ARR_AddList.mp_HeadLink;
ZCLink* VP_RhsHead =ARR_CutList.mp_HeadLink;
TypeSize VL_LhsTempPos=1 ; // VP_LhsTemp 의 위치
bool VB_IsMoved =false;
ZCLink* VP_TempLink =0 ;
do //////
{
if(pf_IsTrueValue(VP_LhsTemp->GetData(), VP_RhsHead->GetData())==true)
{
VP_TempLink=VP_RhsHead ;
VP_RhsHead =VP_RhsHead->mp_NextLink;
ARR_AddList.JoinBefore ////////////////////
(
ARR_CutList.CutLink(VP_TempLink,1),
VP_LhsTemp,
VL_LhsTempPos
);
///////////////////////////////////////////
/* VP_LhsTemp 앞에 링크가 하나 삽입되었으므로,
VP_LhsTemp 의 위치값을 하나 증가시킨다. */
++VL_LhsTempPos; VB_IsMoved=true;
}/*
if(pf_IsTrueValue(VP_LhsTemp->GetData(), VP_RhsHead->GetData())==true)*/
if(ARR_CutList.mp_HeadLink==0) return;
if(VP_LhsTemp==VP_LhsTail)
{
ARR_AddList.JoinTail(ARR_CutList); return;
}/*
if(VP_LhsTemp==VP_LhsTail)*/
if(VB_IsMoved==false)
{
VP_LhsTemp=VP_LhsTemp->mp_NextLink; ++VL_LhsTempPos;
}
else
{
VB_IsMoved=false;
}
}
while(true);
}/*
static void MergeSort
(TTypObjList& ARR_AddList, TTypObjList& ARR_CutList, bool AB_IsAscending=true)
/*#################*/
template<typename TFunctor> void MakeUnique( /*############*/
TTypObjList& ARR_CObjList ,
TFunctor AR_Functor ,
bool AB_IsSorted =false,
bool AB_IsAscending=true
/*#########*/ ) /*#########################################*/
{
// ARR_CObjList 의 각 노드를 유일하게 만든다.
if(AB_IsSorted==false)
QuickSort(ARR_CObjList,AB_IsAscending);
TypeSize VL_LoopSize= ARR_CObjList.GetSize() ;
TypeSize VL_Index = 1 ;
ZCLink* VP_HeadLink= ARR_CObjList.GetHeadLinkPtr();
ZCLink* VP_CutLink = 0 ;
/* VL_LoopSize-1 번 순환하며 같은 원소가 이웃한다면
앞뒤 노드에 대해 어떤 처리를 하고 뒤쪽의 노드를 삭제한다. */
for(TypeSize i=1; i<VL_LoopSize; ++i)
{
if(VP_HeadLink->GetData()==VP_HeadLink->GetNextPtr()->GetData())
{
AR_Functor //////////////////////////
(
VP_HeadLink->GetData(), VP_HeadLink->GetNextPtr()->GetData()
);
VP_CutLink=VP_HeadLink->GetNextPtr();
ARR_CObjList.Delete(VP_CutLink, VL_Index+1);
}
else
{
(VP_HeadLink=VP_HeadLink->GetNextPtr(), ++VL_Index);
}
}/*
for(TypeSize i=1; i<VL_LoopSize; ++i)*/
}/*
template<typename TFunctor> void MakeUnique( ################
TFunctor AR_Functor ,
bool AB_IsSorted=false ,
bool AB_IsAscending=true
################# ) #######################################*/
static void MakeUnique( /*#################################*/
TTypObjList& ARR_CObjList ,
bool AB_IsSorted =false,
bool AB_IsAscending=true
/*#########*/ ) /*#########################################*/
{
// ARR_CObjList 의 각 노드를 유일하게 만든다.
if(AB_IsSorted==false)
QuickSort(ARR_CObjList,AB_IsAscending);
TypeSize VL_LoopSize =ARR_CObjList.GetSize() ;
TypeSize VL_Index =1 ;
ZCLink* VP_HeadLink =ARR_CObjList.GetHeadLinkPtr();
ZCLink* VP_CutLink =0 ;
/* VL_LoopSize-1 번 순환하며 같은 원소가 이웃한다면
뒤쪽의 노드를 삭제한다.
*/
for(TypeSize i=1; i<VL_LoopSize; ++i)
{
if(VP_HeadLink->GetData()==VP_HeadLink->GetNextPtr()->GetData())
{
VP_CutLink = VP_HeadLink->GetNextPtr() ;
ARR_CObjList.Delete(VP_CutLink, VL_Index+1);
}
else
{
(VP_HeadLink=VP_HeadLink->GetNextPtr(), ++VL_Index);
}
}/*
for(TypeSize i=1; i<VL_LoopSize; ++i)*/
}/*
static void MakeUnique( #####################################
TTypObjList& ARR_CObjList ,
bool AB_IsSorted =false,
bool AB_IsAscending=true
############# ) ###########################################*/
template<typename TFunctor> static void SplitGroup( /*#####*/
TTypObjList& ARR_CObjList ,
TFunctor AR_Functor ,
bool AB_IsSorted =false,
bool AB_IsAscending=true
/*#########*/ ) /*#########################################*/
{
/* ARR_CObjList 의 각 노드를 같은 것끼리 그룹으로 묵어서
묶여진 리스트에 대해 AR_Functor 를 수행한다.
*/
if(ARR_CObjList.IsEmpty()) return;
if(AB_IsSorted==false)
{
QuickSort(ARR_CObjList, AB_IsAscending); // 정렬이 안되었으면 정렬을 하고...
}/*
if(AB_IsSorted==false)*/
TypeSize VL_LoopSize=ARR_CObjList.GetSize() ;
TypeSize VL_TailPos =1 ;
ZCLink* VP_CutHead =ARR_CObjList.GetHeadLinkPtr();
ZCLink* VP_CutTail =VP_CutHead ;
ZCLink* VP_CutTemp =VP_CutTail->GetNextPtr() ;
// VL_LoopSize-1 번 순환
for(TypeSize i=2; i<=VL_LoopSize; ++i)
{
if(VP_CutTail->GetData()==VP_CutTemp->GetData())
{
VP_CutTail=VP_CutTemp ;
VP_CutTemp=VP_CutTemp->GetNextPtr() ;
++VL_TailPos;
}
else // VP_CutTail->GetData()!=VP_CutTemp->GetData()
{
/* 다음 노드와 다르면 이전 노드들은 서로 같다는 것이다.
이전 노드들은 functor 로 처리를 넘긴다. functor 는
넘겨받은 리스트를 반드시 써야(삭제해야) 한다. CutLink()
멤버 함수는 내부에 정적 리스트 개체를 가지고 있는데
여기에 쓸데없는 자료가 남겨져서는 안되기 때문이다. */
AR_Functor //////////////////////////////////////
(
ARR_CObjList.CutLink
(
VP_CutHead, 1, VP_CutTail, VL_TailPos
)
);
/////////////////////////////////////////////////
VP_CutHead =VP_CutTemp;
VP_CutTail =VP_CutTemp;
VP_CutTemp =VP_CutTemp->GetNextPtr();
VL_TailPos =1 ;
}/*
else // VP_CutTail->GetData()!=VP_CutTemp->GetData()*/
}/*
for(TypeSize i=2; i<=VL_LoopSize; ++i)*/
if(ARR_CObjList.IsEmpty()==false) AR_Functor(ARR_CObjList);
}/*
template<typename TFunctor> static void SplitGroup( ##########
TTypObjList& ARR_CObjList ,
TFunctor AR_Functor ,
bool AB_IsSorted=false ,
bool AB_IsAscending=true
############# ) ############################################*/
public:
};/*
template<typename TTypObjList> class ZtCSortObjList */
namespace ZNsExam
{
template<typename TTypeInt=int> class ZtExamSortIntList
{
public:
static void ShowElemnet(int AI_Element)
{
cout<<"* Element : "<<AI_Element<<endl;
}
///////////////////////////////////////
static int Main(int AI_ArgCnt=0, const char* APP_ArgVal[]=0)
{
using namespace std; typedef ZNsMain::
ZtCObjList<TTypeInt, TTypeInt> CObjList ;
CObjList VO_CIntList; ///////////////////////////
VO_CIntList.AddTail(10); VO_CIntList.AddTail(1 );
VO_CIntList.AddTail(6 ); VO_CIntList.AddTail(4 );
VO_CIntList.AddTail(7 ); VO_CIntList.AddTail(2 );
VO_CIntList.AddTail(8 ); VO_CIntList.AddTail(5 );
VO_CIntList.AddTail(9 ); VO_CIntList.AddTail(3 );
cout<<"# Sort ASC" <<endl; ZtCSortObjList<CObjList>::
QuickSort(RR(VO_CIntList), true ); VO_CIntList.IterElement(ShowElemnet);
cout<<"# Sort DESC"<<endl; ZtCSortObjList<CObjList>::
QuickSort(RR(VO_CIntList), false); VO_CIntList.IterElement(ShowElemnet);
return 0 ;
}/*
static int Main(int AI_ArgCnt=0, const char* APP_ArgVal[]=0)*/
public:
};/*
template<typename TTypeInt=int> class ZtExamSortIntList*/
}/*
namespace ZNsExam*/
// 단방향 연결리스트에 대한 정렬 클래스이다.
template<typename TTypObjList> class ZtCSortSimList
{
public :
typedef typename TTypObjList::ZCLink ZCLink ;
typedef typename TTypObjList::TypeData TypeData ;
typedef typename TTypObjList::TypeArg TypeArg ;
typedef typename TTypObjList::TypeSize TypeSize ;
private:
static inline void SwapLinkPtr(ZCLink*& APR_LinkI, ZCLink*& APR_LinkJ)
{
ZCLink*
VP_Temp =APR_LinkI;
APR_LinkI=APR_LinkJ;
APR_LinkJ=VP_Temp;
}/*
static inline void SwapLinkPtr( ZCLink*& APR_LinkI, ZCLink*& APR_LinkJ) */
template
<typename TTypFuncIsMore, typename TTypFuncIsLess>
static void QuickSort
(
TTypFuncIsMore APF_IsMore ,
TTypFuncIsLess APF_IsLess ,
ZCLink* APA_LinkPtrArr[],
TypeSize AL_FirstIndex ,
TypeSize AL_LastIndex
)
/*##################################################*/
{
if(AL_FirstIndex<AL_LastIndex)
{
TypeSize i=AL_FirstIndex ;
TypeSize j=AL_LastIndex+1 ;
ZCLink* VP_PivotLinkPtr=APA_LinkPtrArr[i];
do //////
{
while(AL_LastIndex >i && APF_IsLess(APA_LinkPtrArr[++i]->GetData(), VP_PivotLinkPtr->GetData()));
while(AL_FirstIndex<j && APF_IsMore(APA_LinkPtrArr[--j]->GetData(), VP_PivotLinkPtr->GetData()));
if(i<j) SwapLinkPtr(APA_LinkPtrArr[i], APA_LinkPtrArr[j]);
}
while(i<j);
/* SwapLinkPtr(APA_LinkPtrArr[AL_FirstIndex],APA_LinkPtrArr[j]);
위 코드 보다 아래처럼 2 줄로 쓰는게 별도의 스택 변수를 사용하지
않아서 좋다.
*/
APA_LinkPtrArr[AL_FirstIndex]=APA_LinkPtrArr[j];
APA_LinkPtrArr[j ]=VP_PivotLinkPtr ;
QuickSort(APF_IsMore, APF_IsLess, APA_LinkPtrArr, AL_FirstIndex, j-1 );
QuickSort(APF_IsMore, APF_IsLess, APA_LinkPtrArr, j+1, AL_LastIndex);
}/*
if(AL_FirstIndex<AL_LastIndex)*/
}/*
template
<typename TTypFuncIsMore, typename TTypFuncIsLess>
static void QuickSort
(
TTypFuncIsMore APF_IsMore ,
TTypFuncIsLess APF_IsLess ,
ZCLink* APA_LinkPtrArr[],
TypeSize AL_FirstIndex ,
TypeSize AL_LastIndex
)
/*##################################################*/
/*private:*/
public :
template
<typename TTypFuncIsMore, typename TTypFuncIsLess>
static void QuickSort
(
TTypObjList& ARR_CObjList,
TTypFuncIsMore APF_IsMore ,
TTypFuncIsLess APF_IsLess
)
/*##################################################*/
{
if(ARR_CObjList.GetSize()<=1) return;
TypeSize VL_SortSize = ARR_CObjList.GetSize() ;
ZCLink** VPP_LinkPtrArr = new ZCLink*[VL_SortSize];
if(VPP_LinkPtrArr==0)
{
// Add codes for memory over
return;
}/*
if(VPP_LinkPtrArr==0)*/
ZCLink* VP_TempLink =
ARR_CObjList.GetHeadLinkPtr();
TypeSize i=0 ;
for(; i<VL_SortSize; ++i)
{
VPP_LinkPtrArr[i]=VP_TempLink ;
VP_TempLink =VP_TempLink->GetNextPtr();
}
/////////////////////////
QuickSort(APF_IsMore, APF_IsLess, VPP_LinkPtrArr, 0, VL_SortSize-1);
for(i=1; i<VL_SortSize; ++i) // VL_SortSize-1 번 순환
{
ZCLink::JoinLink(VPP_LinkPtrArr[i-1], VPP_LinkPtrArr[i]);
}
////////////////////////////
#if(_CODE_OLD_) // 아래 코드만 빠진다.
ZCLink::MakeCircle(VPP_LinkPtrArr[0], VPP_LinkPtrArr[VL_SortSize-1]);
#else
ARR_CObjList.mp_HeadLink=VPP_LinkPtrArr[0] ;
ARR_CObjList.mp_TailLink=VPP_LinkPtrArr[VL_SortSize-1];
#endif
delete[] VPP_LinkPtrArr;
}/*
template
<typename TTypFuncIsMore, typename TTypFuncIsLess>
static void QuickSort
(
TTypObjList& ARR_CObjList,
TTypFuncIsMore APF_IsMore ,
TTypFuncIsLess APF_IsLess
)
####################################################*/
public:
};/*
template<typename TTypObjList> class ZtCSortSimList */
}/*
namespace ZNsMain*/
#endif //__ZCPPMAIN__ZCSORT_LIST_H__

8335
ZCppMain/ZtCStringEx.H Normal file

File diff suppressed because it is too large Load Diff

993
ZCppMain/ZtCTreeData.H Normal file
View File

@ -0,0 +1,993 @@

#ifndef __ZCPPMAIN__ZCTREEDATA_H__
#define __ZCPPMAIN__ZCTREEDATA_H__
#include "ZCppMain/ZtCObjList.H"
namespace ZNsMain
{
namespace ZNsView
{
template< typename TypeData, typename TypeSize=int
>
class ZtCViewTreeData ////////////////////////////
{
private:
void ShowDepth(TypeSize AI_Depth)
{
__for1(TypeSize, i, AI_Depth) cout<<" ";
}/*
void ShowDepth(TypeSize AI_Depth)*/
public :
ZNsMain::ZNsEnum::ZERun OnDataStart(TypeSize AI_Depth)
{
ShowDepth(AI_Depth); cout<<"▷ OnDataStart:"<<endl;
return ZNsMain::ZNsEnum::ZERun_OK;
}
ZNsMain::ZNsEnum::ZERun OnDataBody(TypeData& AR_TypeData, TypeSize AI_Depth, TypeSize AI_Index=0)
{
ShowDepth(AI_Depth); cout<<" ※ Index="<<AI_Index<<": "<<AR_TypeData<<endl;
return ZNsMain::ZNsEnum::ZERun_OK;
}
ZNsMain::ZNsEnum::ZERun OnDataClose(TypeSize AI_Depth)
{
ShowDepth(AI_Depth); cout<<"◁ OnDataClose:"<<endl;
return ZNsMain::ZNsEnum::ZERun_OK;
}
ZNsMain::ZNsEnum::ZERun OnSubNodeStart(TypeSize AI_Depth, TypeSize AI_NodeCnt)
{
if(AI_NodeCnt<1){ return ZNsMain::ZNsEnum::ZERun_OK; }
ShowDepth(AI_Depth); cout<<"▶ OnSubNodeStart:"<<endl;
return ZNsMain::ZNsEnum::ZERun_OK;
}
ZNsMain::ZNsEnum::ZERun OnSubNodeClose(TypeSize AI_Depth, TypeSize AI_NodeCnt)
{
if(AI_NodeCnt<1){ return ZNsMain::ZNsEnum::ZERun_OK; }
ShowDepth(AI_Depth); cout<<"◀ OnSubNodeClose:"<<endl;
return ZNsMain::ZNsEnum::ZERun_OK;
}/*
ZNsMain::ZNsEnum::ZERun OnSubNodeClose(TypeSize AI_Depth, TypeSize AI_NodeCnt)*/
public:
};/*
template< typename TypeData, typename TypeSize=int
>
class ZtCViewTreeData //////////////////////////*/
}/*
namespace ZNsView*/
namespace ZNsType
{
/*/////////////////////////////////////////////////////////////////////////////////////
■ class ZtCTypeTreeData 템플릿은 정의에서 또 다른 템플릿(list 등의 컨테이너 템플릿)을
포함하고 있음을 눈여겨 보자. 이것을 ZtCTreeData<> 에서 활용하는 부분은 아래처럼
typedef typename TTypeTreeData::template ZtCTypeClass<ZCNode1>::TypeData ZCNode1List;
typedef typename TTypeTreeData::template ZtCTypeClass<ZCNode2>::TypeData ZCNode2List;
다소 복잡해 보인다.
-- 2011-11-01 14:39:00
/////////////////////////////////////////////////////////////////////////////////////*/
template<typename TTypeSize=long> class ZtCTypeTreeData
{
public:
typedef TTypeSize TypeSize;
public:
template< typename TType ,
typename TTypeArg =const TType& ,
typename TTypeAlloc=ZNsMain::ZCAllocator,
typename TTypeInit =ZNsMain::ZtCInit<TType>
>
class ZtCTypeClass /////////////////////////////////
{
public:
typedef TTypeAlloc TypeAlloc;
typedef TTypeInit TypeInit ;
public:
typedef ZNsMain::ZtCObjList
<TType, TTypeArg, TTypeAlloc, TTypeInit, TTypeSize>
TypeList; /////////////////
public:
};/*
template< typename TType ,
typename TTypeArg =const TType& ,
typename TTypeAlloc=ZNsMain::ZCAllocator,
typename TTypeInit =ZNsMain::ZtCInit<TType>
>
class ZtCTypeClass ///////////////////////////////*/
public:
};/*
template<typename TTypeSize=long> class ZtCTypeTreeData*/
}/*
namespace ZNsType*/
template< typename TType ,
typename TTypeInit =ZNsMain::ZtCInit<TType>,
typename TTypeTreeData=ZNsType::ZtCTypeTreeData<long>
>
class ZtCTreeData /*###########################################*/
{
public:
class ZCNode1; class ZCNode2; class ZCNodeInfo;
public:
typedef TType TypeData ;
typedef TTypeInit ZCTypeInit ;
typedef TTypeTreeData ZCTypeTreeData;
public:
typedef typename TTypeTreeData::TypeSize TypeSize ;
typedef typename TTypeTreeData::template
ZtCTypeClass<ZCNode1>::TypeList ZCNode1List ;
typedef typename TTypeTreeData::template
ZtCTypeClass<ZCNode2>::TypeList ZCNode2List ;
public:
typedef ZCNode1 ZCNode ;
typedef ZCNode1List ZCNodeList ;
public:
typedef typename ZCNodeList::ZCLink ZCNodeLink;
typedef typename ZCNodeList::iterator IterOfNode;
public:
class ZCNode1 : public ZCTypeInit
{
public :
friend class ZCNodeInfo;
private:
ZCNode* mp_HighNode ;
TypeData mo_TypeData ;
ZCNode2List mo_CNodeList;
public :
ZCNode1()
{
mp_HighNode=0; this->ZCTypeInit::OnInit(mo_TypeData);
}/*
ZCNode1()*/
~ZCNode1()
{
mp_HighNode=0; this->ZCTypeInit::OnFini(mo_TypeData);
}/*
~ZCNode1()*/
ZCNode* GetHighNodePtr () {return (ZCNode*)mp_HighNode;}
const ZCNode* GetHighNodePtr ()const{return (ZCNode*)mp_HighNode;}
TypeData& GetData () {return mo_TypeData;}
const TypeData& GetData ()const{return mo_TypeData;}
const ZCNodeList& GetCNodeList()const{return (ZCNodeList&)mo_CNodeList;}
TypeSize GetNodeCnt(){return mo_CNodeList.size();}
void DeleteCNodeList(){mo_CNodeList.DeleteAll();}
void clear (){mo_CNodeList.DeleteAll();}
ZCNode& AddSubNode()
{
ZCNode* VP_CNode=(ZCNode*)&(**mo_CNodeList.AddTailDef());
VP_CNode->mp_HighNode=(ZCNode*)this; return *VP_CNode ;
}/*
ZCNode& AddSubNode()*/
ZCNodeInfo GetHeadNodeIter()
{
return ZCNodeInfo((ZCNode*)this, ((ZCNodeList&)mo_CNodeList).GetHeadLinkPtr());
}/*
ZCNodeInfo GetHeadNodeIter()*/
/*//////////////////////////////////////////////////////////////////////////////
■ TViewClass 의 interface
ZNsMain::ZNsEnum::ZERun OnDataBody(TypeData, TypeSize AI_Depth, TypeSize AI_Index=0)
ZNsMain::ZNsEnum::ZERun OnSubNodeStart(int AI_Depth, int AI_NodeCnt)
ZNsMain::ZNsEnum::ZERun OnSubNodeClose(int AI_Depth, int AI_NodeCnt)
-- 2011-10-31 21:53:00
//////////////////////////////////////////////////////////////////////////////*/
template<typename TViewClass> ZNsMain::ZNsEnum::ZERun IterPreOrder
( TViewClass& AR_CViewClass, TypeSize AI_StartDepth=0, TypeSize AI_NodeIndex=0 )
/*##############################################################*/
{
const bool CB_DoStop = ///////////////////////////////
(
AR_CViewClass.OnDataBody
(mo_TypeData, AI_StartDepth, AI_NodeIndex)
== ZNsMain::ZNsEnum::ZERun_NO
);
//////////////////////////////////////////////////////
if(CB_DoStop) return ZNsMain::ZNsEnum::ZERun_NO;
TypeSize VL_NodeCnt= ((ZCNodeList&)mo_CNodeList).size () ;
IterOfNode VO_iter_Node(((ZCNodeList&)mo_CNodeList).begin());
if ( AR_CViewClass. //////////////////////////////////////
OnSubNodeStart(AI_StartDepth, VL_NodeCnt)==
ZNsMain::ZNsEnum::ZERun_NO
)
{ return ZNsMain::ZNsEnum::ZERun_NO; } //////////////////////
++AI_StartDepth;
{
__for1(TypeSize, i, VL_NodeCnt)
{
const bool CB_DoStop =
(
((ZCNodeList&)mo_CNodeList).ItD(VO_iter_Node).
IterPreOrder<TViewClass>
(AR_CViewClass, AI_StartDepth, i)
== ZNsMain::ZNsEnum::ZERun_NO
);
//////////////////////
if(CB_DoStop) return ZNsMain::ZNsEnum::ZERun_NO;
((ZCNodeList&)mo_CNodeList).MoveNextIter(RR(VO_iter_Node));
}/*
__for1(TypeSize, i, VL_NodeCnt)*/
}
--AI_StartDepth;
const ZNsMain::ZNsEnum::ZERun CE_ERun =
AR_CViewClass.OnSubNodeClose(AI_StartDepth, VL_NodeCnt);
if(CE_ERun==ZNsMain::ZNsEnum::ZERun_NO)
return ZNsMain::ZNsEnum::ZERun_NO; /////////////////////
return ZNsMain::ZNsEnum::ZERun_OK;
}/*
template<typename TViewClass> ZNsMain::ZNsEnum::ZERun IterPreOrder
(TViewClass& AR_CViewClass, TypeSize AI_StartDepth=0, TypeSize AI_NodeIndex=0)
/*##############################################################*/
template<typename TViewClass> ZNsMain::ZNsEnum::ZERun IterPostOrder
( TViewClass& AR_CViewClass, TypeSize AI_StartDepth=0, TypeSize AI_NodeIndex=0 )
/*###############################################################*/
{
TypeSize VL_NodeCnt = ((ZCNodeList&)mo_CNodeList).size () ;
IterOfNode VO_iter_Node(((ZCNodeList&)mo_CNodeList).begin());
if(AR_CViewClass.OnSubNodeStart
(AI_StartDepth, VL_NodeCnt)==ZNsMain::ZNsEnum::ZERun_NO)
{ return ZNsMain::ZNsEnum::ZERun_NO; }
++AI_StartDepth; /*####################*/
{
__for1(TypeSize, i, VL_NodeCnt)
{
const bool CB_DoStop =
(
((ZCNodeList&)mo_CNodeList).ItD(VO_iter_Node).
IterPostOrder<TViewClass>(AR_CViewClass, AI_StartDepth, i)
== ZNsMain::ZNsEnum::ZERun_NO
);
//////////////////////
if(CB_DoStop) return ZNsMain::ZNsEnum::ZERun_NO;
((ZCNodeList&)mo_CNodeList).MoveNextIter(VO_iter_Node);
}/*
__for1(TypeSize, i, VL_NodeCnt)*/
}
--AI_StartDepth; /*####################*/
if(AR_CViewClass.OnSubNodeClose
(AI_StartDepth, VL_NodeCnt)==ZNsMain::ZNsEnum::ZERun_NO)
{ return ZNsMain::ZNsEnum::ZERun_NO; }
const bool CB_DoStop = /////////////////////////
(
AR_CViewClass.OnDataBody
( mo_TypeData, AI_StartDepth, AI_NodeIndex )
==ZNsMain::ZNsEnum::ZERun_NO
) ;
////////////////////////////////////////////////
if(CB_DoStop)
{ return ZNsMain::ZNsEnum::ZERun_NO; }
return ZNsMain::ZNsEnum::ZERun_OK;
}/*
template<typename TViewClass> ZNsMain::ZNsEnum::ZERun IterPostOrder
(TViewClass& AR_CViewClass, TypeSize AI_StartDepth=0, TypeSize AI_NodeIndex=0)
/*###############################################################*/
public:
};/*
class ZCNode1*/
class ZCNode2 : public ZCTypeInit
{
public :
friend class ZCNodeInfo;
private:
ZCNode* mp_HighNode ;
TypeData mo_TypeData ;
ZCNode1List mo_CNodeList;
public :
ZCNode2()
{
mp_HighNode=0; this->ZCTypeInit::OnInit(mo_TypeData);
}/*
ZCNode2()*/
~ZCNode2()
{
mp_HighNode=0; this->ZCTypeInit::OnFini(mo_TypeData);
}/*
~ZCNode2()*/
ZCNode* GetHighNodePtr () {return (ZCNode*)mp_HighNode;}
const ZCNode* GetHighNodePtr ()const{return (ZCNode*)mp_HighNode;}
TypeData& GetData () {return mo_TypeData ;}
const TypeData& GetData ()const{return mo_TypeData ;}
const ZCNodeList& GetCNodeList()const{return (ZCNodeList&)mo_CNodeList;}
TypeSize GetNodeCnt(){return mo_CNodeList.size();}
void DeleteCNodeList(){mo_CNodeList.DeleteAll();}
void clear (){mo_CNodeList.DeleteAll();}
ZCNode& AddSubNode()
{
ZCNode* VP_CNode=(ZCNode*)&(**mo_CNodeList.AddTailDef());
VP_CNode->mp_HighNode=(ZCNode*)this; return *VP_CNode ;
}/*
ZCNode& AddSubNode()*/
ZCNodeInfo GetHeadNodeIter()
{
return ZCNodeInfo((ZCNode*)this, ((ZCNodeList&)mo_CNodeList).GetHeadLinkPtr());
}/*
ZCNodeInfo GetHeadNodeIter()*/
/*//////////////////////////////////////////////////////////////////////////////////////////////
■ ZCNode1 과 ZCNode2 가 동일한 구조이므로, ZCNode2 에서는 IterPreOrder() 와 IterPostOrder() 를
정의할 필요없다. ZCNode2 이 ZCNode1 로 형변환되어서 ZCNode1 의 IterPreOrder() 와 IterPostOrder()
을 사용할 것이기 때문이다.
-- 2011-11-01 10:40:00
//////////////////////////////////////////////////////////////////////////////////////////////*/
public:
};/*
class ZCNode2*/
class ZCNodeInfo
{
private:
ZCNode* mp_NowNodeWrap;
ZCNodeLink* mp_NowNodeLink;
public :
ZCNodeInfo(ZCNode* AP_CNode=0, ZCNodeLink* AP_CNodeLink=0)
{
mp_NowNodeWrap=AP_CNode; mp_NowNodeLink=AP_CNodeLink;
}/*
ZCNodeInfo(ZCNode* AP_CNode=0, ZCNodeLink* AP_CNodeLink=0)*/
ZCNode* GetNowNodeWrap(){return mp_NowNodeWrap;}
ZCNodeLink* GetNowNodeLink(){return mp_NowNodeLink;}
bool DeleteNode()
{
if(mp_NowNodeWrap==0 || mp_NowNodeLink==0) return false;
((ZCNodeList&)(mp_NowNodeWrap->mo_CNodeList)).
DeleteLink(mp_NowNodeLink);
mp_NowNodeLink=0; return true; ///////////////
}/*
bool DeleteNode()*/
ZCNodeInfo& operator ++ (int)
{mp_NowNodeWrap->mo_CNodeList.MoveNextIter(mp_NowNodeLink); return *this;}
ZCNode& operator*() {return mp_NowNodeWrap->mo_CNodeList.ItD(mp_NowNodeLink);}
const ZCNode& operator*()const{return mp_NowNodeWrap->mo_CNodeList.ItD(mp_NowNodeLink);}
public:
};/*
class ZCNodeInfo*/
/*public :*/
private:
ZCNode mo_RootNode;
public :
ZCNode& GetRootNode() {return mo_RootNode;}
const ZCNode& GetRootNode()const{return mo_RootNode;}
void DeleteAll(){mo_RootNode.clear();}
void clear (){mo_RootNode.clear();}
/*/////////////////////////////////////////////////////////////////////////////////////////
■ 위 clear() 함수는 mo_RootNode.clear() 를 호출하고 있는데, 만약 mo_RootNode.mo_TypeData
가 컨테이너 인 경우, mo_TypeData 를 추가로 초기화하는 코드가 필요할 수 있다. 이에 대해서
는 CXmlInfo_T<>::clear() 을 참고한다.
-- 2012-10-12 13:20:00
/////////////////////////////////////////////////////////////////////////////////////////*/
template<typename TViewClass> void IterPreOrder(TViewClass& AR_CViewClass)
{
mo_RootNode.IterPreOrder<TViewClass>(AR_CViewClass, 0, 0);
}/*
template<typename TViewClass> void IterPreOrder(TViewClass& AR_CViewClass) */
template<typename TViewClass> void IterPostOrder(TViewClass& AR_CViewClass)
{
mo_RootNode.IterPostOrder<TViewClass>(AR_CViewClass, 0, 0);
}/*
template<typename TViewClass> void IterPostOrder(TViewClass& AR_CViewClass) */
public:
};/*
template< typename TType ,
typename TTypeInit =ZNsMain::ZtCInit<TType>,
typename TTypeTreeData=ZNsType::ZtCTypeTreeData<long>
>
class ZtCTreeData #############################################*/
/*///////////////////////////////////////////////////////////////
■ class ZtCTreeData 예제 -- 2015-08-14 14:00
#include <iostream>
#include "ZCppMain/ZtCTreeData.H"
using namespace std ;
using namespace ZNsMain;
typedef ZtCStringBase<char> CStringBase ;
typedef ZtCTreeData<CStringBase> CStrTreeData ;
typedef CStrTreeData::ZCNode CNodeCStr ;
typedef ZNsMain::ZNsView::
ZtCViewTreeData<CStringBase> CViewTreeData;
int main()
{
CStringBase VO_CStringBase ;
CStrTreeData VO_CStrTreeData ;
CViewTreeData VO_CViewTreeData;
CNodeCStr& VO_CNodeCStr1 = VO_CStrTreeData.GetRootNode().AddSubNode();
CNodeCStr& VO_CNodeCStr2 = VO_CStrTreeData.GetRootNode().AddSubNode();
CNodeCStr& VO_CNodeCStr3 = VO_CStrTreeData.GetRootNode().AddSubNode();
CNodeCStr& VO_CNodeCStr11 = VO_CNodeCStr1 .AddSubNode();
CNodeCStr& VO_CNodeCStr12 = VO_CNodeCStr1 .AddSubNode();
CNodeCStr& VO_CNodeCStr121= VO_CNodeCStr12.AddSubNode();
CNodeCStr& VO_CNodeCStr122= VO_CNodeCStr12.AddSubNode();
CNodeCStr& VO_CNodeCStr21 = VO_CNodeCStr2 .AddSubNode();
CNodeCStr& VO_CNodeCStr22 = VO_CNodeCStr2 .AddSubNode();
VO_CStrTreeData.GetRootNode().GetData()="## Root Node ##";
VO_CNodeCStr1 . GetData()="Node1" ;
VO_CNodeCStr2 . GetData()="Node2" ;
VO_CNodeCStr3 . GetData()="Node3" ;
VO_CNodeCStr11. GetData()="Node11" ;
VO_CNodeCStr12. GetData()="Node12" ;
VO_CNodeCStr21. GetData()="Node21" ;
VO_CNodeCStr22. GetData()="Node22" ;
VO_CNodeCStr121.GetData()="Node121";
VO_CNodeCStr122.GetData()="Node122";
cout<<"# Pre Order"<<endl;
VO_CStrTreeData.IterPreOrder (VO_CViewTreeData);
cout<<"# Post Order" <<endl;
VO_CStrTreeData.IterPostOrder(VO_CViewTreeData);
}
□ 출력
# Pre Order
※ Index=0: ## Root Node ##
▶ OnSubNodeStart:
※ Index=1: Node1
▶ OnSubNodeStart:
※ Index=1: Node11
※ Index=2: Node12
▶ OnSubNodeStart:
※ Index=1: Node121
※ Index=2: Node122
◀ OnSubNodeClose:
◀ OnSubNodeClose:
※ Index=2: Node2
▶ OnSubNodeStart:
※ Index=1: Node21
※ Index=2: Node22
◀ OnSubNodeClose:
※ Index=3: Node3
◀ OnSubNodeClose:
# Post Order
▶ OnSubNodeStart:
▶ OnSubNodeStart:
※ Index=1: Node11
▶ OnSubNodeStart:
※ Index=1: Node121
※ Index=2: Node122
◀ OnSubNodeClose:
※ Index=2: Node12
◀ OnSubNodeClose:
※ Index=1: Node1
▶ OnSubNodeStart:
※ Index=1: Node21
※ Index=2: Node22
◀ OnSubNodeClose:
※ Index=2: Node2
※ Index=3: Node3
◀ OnSubNodeClose:
※ Index=0: ## Root Node ##
///////////////////////////////////////////////////////////////*/
/*///////////////////////////////////////////////////////////////
■ class ZtCTreeData <>::ZCNode1 에는 mo_TypeData 이 있다면,
class ZtCTreeDataEx<>::ZCNode1 에는 mo_CDataList 이 있다.
///////////////////////////////////////////////////////////////*/
template< typename TType,
typename TTypeTreeData=ZNsType::ZtCTypeTreeData<long>
>
class ZtCTreeDataEx /*#########################################*/
{
public:
typedef TType TypeData ;
typedef TTypeTreeData ZCTypeTreeData;
public:
class ZCNode1; class ZCNode2; class ZCNodeInfo ;
public:
typedef typename TTypeTreeData::TypeSize TypeSize;
public:
typedef typename TTypeTreeData::
template ZtCTypeClass<TypeData>::TypeList ZCDataList ;
typedef typename TTypeTreeData::
template ZtCTypeClass<ZCNode1 >::TypeList ZCNode1List;
typedef typename TTypeTreeData::
template ZtCTypeClass<ZCNode2 >::TypeList ZCNode2List;
public:
typedef ZCNode1 ZCNode ;
typedef ZCNode1List ZCNodeList;
typedef typename ZCNodeList::ZCLink ZCNodeLink;
typedef typename ZCDataList::ZCLink ZCDataLink;
public:
typedef typename ZCDataList::iterator IterOfData;
typedef typename ZCNodeList::iterator IterOfNode;
public:
class ZCNode1
{
public :
friend class ZCNodeInfo;
private:
ZCNode* mp_HighNode ;
ZCDataList mo_CDataList;
ZCNode2List mo_CNodeList;
public :
ZCNode1()
{
mp_HighNode=0;
}/*
ZCNode1()*/
ZCNode* GetHighNodePtr() {return (ZCNode*)mp_HighNode;}
const ZCNode* GetHighNodePtr()const{return (ZCNode*)mp_HighNode;}
ZCDataList& GetZCDataList() {return mo_CDataList;}
const ZCDataList& GetZCDataList()const{return mo_CDataList;}
const ZCNodeList& GetCNodeList()const{return (ZCNodeList&)mo_CNodeList;}
TypeSize GetDataCnt(){return mo_CDataList.size();}
TypeSize GetNodeCnt(){return mo_CNodeList.size();}
void DeleteCDataList(){mo_CDataList.DeleteAll();}
void DeleteCNodeList(){mo_CNodeList.DeleteAll();}
void DeleteAll (){mo_CDataList.DeleteAll(); mo_CNodeList.DeleteAll();}
void clear (){DeleteAll();}
ZCNode& AddSubNode()
{
ZCNode* VP_CNode=(ZCNode*)&(**mo_CNodeList.AddTailDef());
VP_CNode->mp_HighNode=(ZCNode*)this; return *VP_CNode ;
}/*
ZCNode& AddSubNode()*/
ZCNodeInfo GetHeadNodeIter()
{
return ZCNodeInfo((ZCNode*)this, ((ZCNodeList&)mo_CNodeList).GetHeadLinkPtr());
}/*
ZCNodeInfo GetHeadNodeIter()*/
/*//////////////////////////////////////////////////////////////////////////////
■ TViewClass 의 interface
ZNsMain::ZNsEnum::ZERun OnDataStart(int AI_Depth)
ZNsMain::ZNsEnum::ZERun OnDataBody(TypeData, TypeSize AI_Depth, TypeSize AI_Index)
ZNsMain::ZNsEnum::ZERun OnDataClose(int AI_Depth)
ZNsMain::ZNsEnum::ZERun OnSubNodeStart(int AI_Depth, int AI_NodeCnt)
ZNsMain::ZNsEnum::ZERun OnSubNodeClose(int AI_Depth, int AI_NodeCnt)
-- 2011-10-31 21:53:00
//////////////////////////////////////////////////////////////////////////////*/
template<typename TViewClass> ZNsMain::ZNsEnum::ZERun IterPreOrder
(
TViewClass& AR_CViewClass ,
TypeSize AI_StartDepth=0,
TypeSize AI_NodeIndex =0
)
/*##############################################################*/
{
TypeSize VL_DataCnt= mo_CDataList .size();
TypeSize VL_NodeCnt=((ZCNodeList&)mo_CNodeList).size();
IterOfData VO_iter_Data( mo_CDataList.begin());
IterOfNode VO_iter_Node(((ZCNodeList&)mo_CNodeList).begin());
if(AR_CViewClass.OnDataStart(AI_StartDepth)==ZNsMain::ZNsEnum::ZERun_NO)
{ return ZNsMain::ZNsEnum::ZERun_NO; }
/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
{
__for1(TypeSize, i, VL_DataCnt)
{
const bool CB_DoStop =
(
AR_CViewClass.OnDataBody
(
mo_CDataList.ItD(VO_iter_Data), AI_StartDepth, AI_NodeIndex
)
== ZNsMain::ZNsEnum::ZERun_NO
);
//////////////////////
if(CB_DoStop) return ZNsMain::ZNsEnum::ZERun_NO;
mo_CDataList.MoveNextIter(VO_iter_Data); ///////
}/*
__for1(TypeSize, i, VL_DataCnt)*/
}
if(AR_CViewClass.OnDataClose(AI_StartDepth)==ZNsMain::ZNsEnum::ZERun_NO)
{ return ZNsMain::ZNsEnum::ZERun_NO; }
/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
if(AR_CViewClass.OnSubNodeStart
(AI_StartDepth, VL_NodeCnt)==ZNsMain::ZNsEnum::ZERun_NO)
{ return ZNsMain::ZNsEnum::ZERun_NO; }
++AI_StartDepth; /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
{
__for1(TypeSize, i, VL_NodeCnt)
{
const bool CB_DoStop = ///////////////////////////////
(
((ZCNodeList&)mo_CNodeList).ItD(VO_iter_Node).
IterPreOrder<TViewClass>
(AR_CViewClass, AI_StartDepth. i)
== ZNsMain::ZNsEnum::ZERun_NO
);
//////////////////////////////////////////////////////
if(CB_DoStop) return ZNsMain::ZNsEnum::ZERun_NO;
((ZCNodeList&)mo_CNodeList).MoveNextIter(VO_iter_Node);
}/*
__for1(TypeSize, i, VL_NodeCnt)*/
}
--AI_StartDepth; /*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
if(AR_CViewClass.OnSubNodeClose
(AI_StartDepth, VL_NodeCnt)==ZNsMain::ZNsEnum::ZERun_NO)
{ return ZNsMain::ZNsEnum::ZERun_NO; }
return ZNsMain::ZNsEnum::ZERun_OK; /////////////////////////
}/*
template<typename TViewClass> ZNsMain::ZNsEnum::ZERun IterPreOrder
(
TViewClass& AR_CViewClass, TypeSize AI_StartDepth=0
TypeSize AI_NodeIndex =0
) */
/*###############################################################*/
template<typename TViewClass> ZNsMain::ZNsEnum::ZERun IterPostOrder
(
TViewClass& AR_CViewClass ,
TypeSize AI_StartDepth=0,
TypeSize AI_NodeIndex =0
)
/*###############################################################*/
{
TypeSize VL_DataCnt= mo_CDataList. size();
TypeSize VL_NodeCnt=((ZCNodeList&)mo_CNodeList).size();
IterOfData VO_iter_Data( mo_CDataList. begin());
IterOfNode VO_iter_Node(((ZCNodeList&)mo_CNodeList).begin());
if(AR_CViewClass.OnSubNodeStart
(AI_StartDepth, VL_NodeCnt)==ZNsMain::ZNsEnum::ZERun_NO)
{ return ZNsMain::ZNsEnum::ZERun_NO; }
++AI_StartDepth; /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
{
__for1(TypeSize, i, VL_NodeCnt)
{
const bool CB_DoStop = ////////////////////////////////
(
((ZCNodeList&)mo_CNodeList).
ItD(VO_iter_Node).IterPostOrder<TViewClass>
(AR_CViewClass, AI_StartDepth, i)
== ZNsMain::ZNsEnum::ZERun_NO
);
///////////////////////////////////////////////////////
if(CB_DoStop) return ZNsMain::ZNsEnum::ZERun_NO;
((ZCNodeList&)mo_CNodeList).MoveNextIter(VO_iter_Node);
}/*
__for1(TypeSize, i, VL_NodeCnt)*/
}
--AI_StartDepth; /*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
if(AR_CViewClass.OnSubNodeClose
(AI_StartDepth, VL_NodeCnt)==ZNsMain::ZNsEnum::ZERun_NO)
{ return ZNsMain::ZNsEnum::ZERun_NO; }
if(AR_CViewClass.OnDataStart(AI_StartDepth)==ZNsMain::ZNsEnum::ZERun_NO)
{ return ZNsMain::ZNsEnum::ZERun_NO; }
/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
{
__for1(TypeSize, i, VL_DataCnt)
{
const bool CB_DoStop = ////////////////////
(
AR_CViewClass.OnDataBody
(
mo_CDataList.ItD(VO_iter_Data), AI_StartDepth, AI_NodeIndex
)
== ZNsMain::ZNsEnum::ZERun_NO
);
///////////////////////////////////////////
if(CB_DoStop) return ZNsMain::ZNsEnum::ZERun_NO;
mo_CDataList.MoveNextIter(VO_iter_Data); ///////////////
}/*
__for1(TypeSize, i, VL_DataCnt)*/
}
if(AR_CViewClass.OnDataClose(AI_StartDepth)==ZNsMain::ZNsEnum::ZERun_NO)
{ return ZNsMain::ZNsEnum::ZERun_NO; }
/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
return ZNsMain::ZNsEnum::ZERun_OK;
}/*
template<typename TViewClass> ZNsMain::ZNsEnum::ZERun IterPostOrder
(
TViewClass& AR_CViewClass ,
TypeSize AI_StartDepth=0 ,
TypeSize AI_NodeIndex =0
)
#################################################################*/
public:
};/*
class ZCNode1*/
class ZCNode2
{
public :
friend class ZCNodeInfo;
private:
ZCNode* mp_HighNode ;
ZCDataList mo_CDataList;
ZCNode1List mo_CNodeList;
public :
ZCNode2()
{
mp_HighNode=0;
}/*
ZCNode2()*/
ZCNode* GetHighNodePtr() {return (ZCNode*)mp_HighNode;}
const ZCNode* GetHighNodePtr()const{return (ZCNode*)mp_HighNode;}
ZCDataList& GetZCDataList() {return mo_CDataList;}
const ZCDataList& GetZCDataList()const{return mo_CDataList;}
const ZCNodeList& GetCNodeList ()const{return (ZCNodeList&)mo_CNodeList;}
TypeSize GetDataCnt(){return mo_CDataList.size();}
TypeSize GetNodeCnt(){return mo_CNodeList.size();}
void DeleteCDataList(){mo_CDataList.DeleteAll();}
void DeleteCNodeList(){mo_CNodeList.DeleteAll();}
void DeleteAll (){mo_CDataList.DeleteAll(); mo_CNodeList.DeleteAll();}
void clear (){DeleteAll();}
ZCNode& AddSubNode()
{
ZCNode* VP_CNode=(ZCNode*)&
( **mo_CNodeList.AddTailDef() );
VP_CNode->mp_HighNode=(ZCNode*)this; return *VP_CNode;
}/*
ZCNode& AddSubNode()*/
ZCNodeInfo GetHeadNodeIter()
{
return ZCNodeInfo((ZCNode*)this, ((ZCNodeList&)mo_CNodeList).GetHeadLinkPtr());
}/*
ZCNodeInfo GetHeadNodeIter()*/
/*//////////////////////////////////////////////////////////////////////////////////////////////
■ ZCNode1 과 ZCNode2 가 동일한 구조이므로, ZCNode2 에서는 IterPreOrder() 와 IterPostOrder() 를
정의할 필요없다. ZCNode2 이 ZCNode1 로 형변환되어서 ZCNode1 의 IterPreOrder() 와 IterPostOrder()
을 사용할 것이기 때문이다.
-- 2011-11-01 10:40:00
//////////////////////////////////////////////////////////////////////////////////////////////*/
public:
};/*
class ZCNode2*/
class ZCNodeInfo
{
private:
ZCNode* mp_NowNodeWrap;
ZCNodeLink* mp_NowNodeLink;
public :
ZCNodeInfo(ZCNode* AP_CNode=0,ZCNodeLink* AP_CNodeLink=0)
{
mp_NowNodeWrap=AP_CNode; mp_NowNodeLink=AP_CNodeLink;
}/*
ZCNodeInfo(ZCNode* AP_CNode=0,ZCNodeLink* AP_CNodeLink=0)*/
ZCNode* GetNowNodeWrap(){return mp_NowNodeWrap;}
ZCNodeLink* GetNowNodeLink(){return mp_NowNodeLink;}
bool DeleteNode()
{
if(mp_NowNodeWrap==0 || mp_NowNodeLink==0) return false;
((ZCNodeList&)(mp_NowNodeWrap->mo_CNodeList)).
DeleteLink(mp_NowNodeLink);
mp_NowNodeLink=0; return true; //////////////
}/*
bool DeleteNode()*/
ZCNodeInfo& operator++(int)
{
mp_NowNodeWrap->mo_CNodeList.MoveNextIter(mp_NowNodeLink); return *this;
}/*
ZCNodeInfo& operator++(int)*/
ZCNode& operator*() {return mp_NowNodeWrap->mo_CNodeList.ItD(mp_NowNodeLink);}
const ZCNode& operator*()const{return mp_NowNodeWrap->mo_CNodeList.ItD(mp_NowNodeLink);}
public:
};/*
class ZCNodeInfo
public :*/
private:
ZCNode mo_RootNode;
public:
ZCNode& GetRootNode() {return mo_RootNode;}
const ZCNode& GetRootNode()const{return mo_RootNode;}
void DeleteAll(){mo_RootNode.clear();}
void clear (){mo_RootNode.clear();}
template<typename TViewClass> void IterPreOrder (TViewClass AO_CViewClass)
{ mo_RootNode.IterPreOrder<TViewClass>(AO_CViewClass, 0); }
template<typename TViewClass> void IterPostOrder(TViewClass AO_CViewClass)
{ mo_RootNode.IterPostOrder<TViewClass>(AO_CViewClass, 0); }
public:
};/*
template< typename TType,
typename TTypeTreeData=ZNsType::ZtCTypeTreeData<long>
>
ZtCTreeDataEx #################################################*/
}/*
namespace ZNsMain*/
/*//////////////////////////////////////////////////////////////////////////////////////////
■ 이 파일은 CTreeClass.H 파일을 대체할 것이다. CTreeClass.H 에서는 트리 구조를 표현하는데,
아래 형식의
class CMyNode;
{
public:
TypeData mo_TypeData;
ZNsMain::ZtCObjList<CMyNode> mo_NodeList; // 하위 노드 리스트.
};
재귀 용법을 구현할 수가 없어서, void* 를 사용하였다. 그러나 이 파일에서는, 똑같은 구조의
두 클래스 ZCNode1, ZCNode2 를 사용함으로써, 멋지게(!!) 재귀를 구현하고 있다.
클래스 ZCNode1 에서는 ZCNode2 의 컨테이너(리스트)를 가지고 있고,
클래스 ZCNode2 에서는 ZCNode1 의 컨테이너(리스트)를 가지고 있다.
아주 깜찍하고, 기발한 방법이라고 아니할 수 없다.
2011-10-29 일 토요일, 저녁 7 시 군포시예술문화회관 공연을 보고 오면서, 먼저 선언된 object
에서, 나중에 선언된 object 의 instance 를 참조하는 경우, 매끄럽게 해결할 수 있을 지도 모
르는 방법이 머릿 속에 그려지면서, 운명은 내편이라는 강한 확신이 들었었다. 그러나 집에 도
착 후, 조사 결과, 기대했던 매끄러운 방법은 아니었음이 드러났다. 실망할 수도 있었던 그 순
간, 트리를 구현할 때, 똑깥은 구조의, 이름만 다른 2 개의 클래스로 트리의 재귀 구조를 구현
할 수 있다는 생각이 번개처럼 떠 오른 것이다. 그 결과물이 이 파일 CTreeData.H 이다.
그래, 운명은 내편이었어.
어느덧 해는 저무는데, 이제는 모든 것을 뒤에 두고 떠날 수 있는 날이, 바로 앞에 성큼 다가왔
다.
-- 2011-10-31 23:47:00
-- 현재 CTreeClass.H 는 제거되었다. -- 2013-05-01 17:22:00
//////////////////////////////////////////////////////////////////////////////////////////*/
#endif // __ZCPPMAIN__ZCTREEDATA_H__

242
ZCppMain/test.cpp Normal file
View 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..
/////////////////////////////////////*/