DCL 4.0
Loading...
Searching...
No Matches
LIST_T Class Reference

#include <__LIST.h>

Inheritance diagram for LIST_T:
Object

Classes

class  ConstIterator
class  Iterator
struct  ListNode
class  ReverseConstIterator
class  ReverseIterator

Public Member Functions

virtual ~LIST_T ()
 LIST_T ()
 LIST_T (const LIST_T &_src)
const LIST_Toperator= (const LIST_T &_src)
ConstIterator begin () const
ConstIterator end () const
Iterator begin ()
Iterator end ()
ReverseConstIterator rbegin () const
ReverseConstIterator rend () const
ReverseIterator rbegin ()
ReverseIterator rend ()
Iterator insert (Iterator _pos, CONST_ELEMENT_REF _element)
void insert (Iterator _pos, ConstIterator _first, ConstIterator _last)
Iterator find (CONST_ELEMENT_REF _element)
Iterator erase (Iterator _pos)
void splice (Iterator _pos, LIST_T &_other, Iterator _otherFirst, Iterator _otherLast)
LIST_Tadd (CONST_ELEMENT_REF _element)
LIST_TaddHead (CONST_ELEMENT_REF _element)
LIST_TaddTail (CONST_ELEMENT_REF _element)
ELEMENT_T removeHead ()
ELEMENT_T removeTail ()
void clear ()
bool isEmpty () const
size_t size () const
Public Member Functions inherited from Object
virtual String toString () const
virtual void destroy ()
String className () const
bool isInstanceOf (const std::type_info &typeinfo) const
virtual const std::type_info & typeInfo () const

Protected Member Functions

size_t size (ConstIterator _first, ConstIterator _last) const
void move (Iterator posTo, Iterator _first, Iterator _last)
ListNodecreateNode (CONST_ELEMENT_REF _element)
void destroyNode (ListNode *_pNode)
Protected Member Functions inherited from Object
virtual ~Object ()
 Object ()

Protected Attributes

NodeBase__pMasterNode
size_t __size

Detailed Description

template class List의 DSO 호환성을 제공한다.

C++의 template class는 해당 코드를 사용하기 전에는 실제 이진 코드를 생성하지 않으므로, DSO(so, DLL)와 DSO, 또는 실행파일에서 객체를 주고받을 수 없다.

이 클래스는 DSO의 이러한 문제를 해결하며, 포함파일은 <dcl/List.h>이다.

이 코드를 사용하는 클래스는 다음과 같다.

  • class DCLCAPI StringList
  • class DCLCAPI ByteStringList
  • class DCLCAPI PointerList
See also
List

Definition at line 51 of file __LIST.h.

Constructor & Destructor Documentation

◆ ~LIST_T()

virtual LIST_T::~LIST_T ( )
virtual

◆ LIST_T() [1/2]

LIST_T::LIST_T ( )

Definition at line 76 of file __LIST.cpp.

77{
78 __pMasterNode = (NodeBase*) malloc(sizeof(NodeBase));
79 // FIXME!
80 // if (pNode == NULL)
81 // throw new BadAllocException(sizeof(HashNode), __THIS_FILE__, __LINE__);
83
86 __size = 0;
87}
#define NULL
Definition Config.h:340
#define __DCL_ASSERT(expr)
Definition Object.h:371
NodeBase * __pMasterNode
Definition __LIST.h:169
size_t __size
Definition __LIST.h:170

◆ LIST_T() [2/2]

LIST_T::LIST_T ( const LIST_T & _src)

Definition at line 89 of file __LIST.cpp.

90{
91 __pMasterNode = (NodeBase*) malloc(sizeof(NodeBase));
92 // FIXME!
93 // if (pNode == NULL)
94 // throw new BadAllocException(sizeof(HashNode), __THIS_FILE__, __LINE__);
96
99 __size = 0;
100
101 insert(end(), _src.begin(), _src.end());
102}
ConstIterator end() const
Definition __LIST.h:513
ConstIterator begin() const
Definition __LIST.h:506
Iterator insert(Iterator _pos, CONST_ELEMENT_REF _element)
Definition __LIST.cpp:150

Member Function Documentation

◆ add()

LIST_T & LIST_T::add ( CONST_ELEMENT_REF _element)
inline

Definition at line 592 of file __LIST.h.

593{
594 insert(end(), _element);
595 return *this;
596}

◆ addHead()

LIST_T & LIST_T::addHead ( CONST_ELEMENT_REF _element)
inline

Definition at line 576 of file __LIST.h.

577{
578 insert(begin(), _element);
579 return *this;
580}

◆ addTail()

LIST_T & LIST_T::addTail ( CONST_ELEMENT_REF _element)
inline

Definition at line 584 of file __LIST.h.

585{
586 insert(end(), _element);
587 return *this;
588}

◆ begin() [1/2]

LIST_T::Iterator LIST_T::begin ( )
inline

Definition at line 520 of file __LIST.h.

521{
522 return __pMasterNode->pNext;
523}

◆ begin() [2/2]

LIST_T::ConstIterator LIST_T::begin ( ) const
inline

Definition at line 506 of file __LIST.h.

507{
508 return __pMasterNode->pNext;
509}

◆ clear()

void LIST_T::clear ( )

Definition at line 185 of file __LIST.cpp.

186{
187 ListNode* pNodeTemp = NULL;
188 NodeBase* pNode = __pMasterNode->pNext;
189 while(pNode != __pMasterNode)
190 {
191 pNodeTemp = (ListNode*)pNode;
192 pNode = pNode->pNext;
193 destroyNode(pNodeTemp);
194 }
197 __size = 0;
198}
void destroyNode(ListNode *_pNode)
Definition __LIST.cpp:141
NodeBase * pNext
Definition ListBase.h:19

◆ createNode()

LIST_T::ListNode * LIST_T::createNode ( CONST_ELEMENT_REF _element)
protected

Definition at line 117 of file __LIST.cpp.

118{
119 ListNode* pNode = (ListNode*) malloc(sizeof(ListNode));
120 // FIXME!
121 // if (pNode == NULL)
122 // throw new BadAllocException(sizeof(HashNode), __THIS_FILE__, __LINE__);
123
124#if __DCL_HAVE_ALLOC_DEBUG
125#undef new
126#endif
127
128#if HAVE_CONSTRUCTOR_ELEMENT
129 new(&(pNode->data)) ELEMENT_T;
130#endif
131
132#if __DCL_HAVE_ALLOC_DEBUG
133#define new __DCL_DEBUG_NEW
134#endif
135
136 pNode->data = ELEMENT_T_CAST _element;
137 return pNode;
138}
ELEMENT_T data
Definition __LIST.h:60

◆ destroyNode()

void LIST_T::destroyNode ( ListNode * _pNode)
protected

Definition at line 141 of file __LIST.cpp.

142{
143#if HAVE_CONSTRUCTOR_ELEMENT
144 _pNode->data.~ELEMENT_T();
145#endif
146 free(_pNode);
147}

◆ end() [1/2]

LIST_T::Iterator LIST_T::end ( )
inline

Definition at line 527 of file __LIST.h.

528{
529 return __pMasterNode;
530}

◆ end() [2/2]

LIST_T::ConstIterator LIST_T::end ( ) const
inline

Definition at line 513 of file __LIST.h.

514{
515 return __pMasterNode;
516}

◆ erase()

LIST_T::Iterator LIST_T::erase ( Iterator _pos)

Definition at line 201 of file __LIST.cpp.

202{
203 __DCL_ASSERT(_pos != end());
204 ListNode* pNodeTemp = (ListNode*)_pos.__pNode;
205 NodeBase* pNext = pNodeTemp->pNext;
206 pNodeTemp->pPrev->pNext = pNodeTemp->pNext;
207 pNodeTemp->pNext->pPrev = pNodeTemp->pPrev;
208 destroyNode(pNodeTemp);
209 __size--;
210 return (ListNode*)pNext;
211}

◆ find()

LIST_T::Iterator LIST_T::find ( CONST_ELEMENT_REF _element)

Definition at line 173 of file __LIST.cpp.

174{
175 Iterator it = begin();
176 for (; it != end(); it++)
177 {
178 if (*it == _element)
179 break;
180 }
181 return it;
182}

◆ insert() [1/2]

LIST_T::Iterator LIST_T::insert ( Iterator _pos,
CONST_ELEMENT_REF _element )

Definition at line 150 of file __LIST.cpp.

151{
152 ListNode* pNewNode = createNode(_element);
153 pNewNode->pPrev = _pos.__pNode->pPrev;
154 pNewNode->pNext = _pos.__pNode;
155 _pos.__pNode->pPrev->pNext = pNewNode;
156 _pos.__pNode->pPrev = pNewNode;
157
158 __size++;
159
160 return (ListNode*)pNewNode;
161}
ListNode * createNode(CONST_ELEMENT_REF _element)
Definition __LIST.cpp:117

◆ insert() [2/2]

void LIST_T::insert ( Iterator _pos,
ConstIterator _first,
ConstIterator _last )

Definition at line 164 of file __LIST.cpp.

165{
166 for(; _first != _last; _first++)
167 {
168 insert(_pos, *_first);
169 }
170}

◆ isEmpty()

bool LIST_T::isEmpty ( ) const
inline

Definition at line 562 of file __LIST.h.

563{
564 return __pMasterNode->pNext == __pMasterNode;
565}

◆ move()

void LIST_T::move ( Iterator posTo,
Iterator _first,
Iterator _last )
protected

Definition at line 233 of file __LIST.cpp.

234{
235 if (_pos != _last)
236 {
237 _last.__pNode->pPrev->pNext = _pos.__pNode;
238 _first.__pNode->pPrev->pNext = _last.__pNode;
239 _pos.__pNode->pPrev->pNext = _first.__pNode;
240
241 NodeBase* pTemp = _pos.__pNode->pPrev;
242 _pos.__pNode->pPrev = _last.__pNode->pPrev;
243 _last.__pNode->pPrev = _first.__pNode->pPrev;
244 _first.__pNode->pPrev = pTemp;
245 }
246}

◆ operator=()

const LIST_T & LIST_T::operator= ( const LIST_T & _src)

Definition at line 105 of file __LIST.cpp.

106{
107 if (&_src != this)
108 {
109 if (!isEmpty())
110 clear();
111 insert(end(), _src.begin(), _src.end());
112 }
113 return *this;
114}
bool isEmpty() const
Definition __LIST.h:562
void clear()
Definition __LIST.cpp:185

◆ rbegin() [1/2]

LIST_T::ReverseIterator LIST_T::rbegin ( )
inline

Definition at line 548 of file __LIST.h.

549{
550 return __pMasterNode->pPrev;
551}

◆ rbegin() [2/2]

LIST_T::ReverseConstIterator LIST_T::rbegin ( ) const
inline

Definition at line 534 of file __LIST.h.

535{
536 return __pMasterNode->pPrev;
537}

◆ removeHead()

ELEMENT_T LIST_T::removeHead ( )

Definition at line 214 of file __LIST.cpp.

215{
217 ELEMENT_T result = *begin();
218 erase(begin());
219 return result;
220}
return result
Iterator erase(Iterator _pos)
Definition __LIST.cpp:201

◆ removeTail()

ELEMENT_T LIST_T::removeTail ( )

Definition at line 223 of file __LIST.cpp.

224{
226 Iterator it = end();
227 ELEMENT_T result = *(--it);
228 erase(it);
229 return result;
230}

◆ rend() [1/2]

LIST_T::ReverseIterator LIST_T::rend ( )
inline

Definition at line 555 of file __LIST.h.

556{
557 return __pMasterNode;
558}

◆ rend() [2/2]

LIST_T::ReverseConstIterator LIST_T::rend ( ) const
inline

Definition at line 541 of file __LIST.h.

542{
543 return __pMasterNode;
544}

◆ size() [1/2]

size_t LIST_T::size ( ) const
inline

Definition at line 569 of file __LIST.h.

570{
571 return __size;
572}

◆ size() [2/2]

size_t LIST_T::size ( ConstIterator _first,
ConstIterator _last ) const
protected

Definition at line 261 of file __LIST.cpp.

262{
263 size_t nCount = 0;
264 for(; _first != _last; _first++)
265 nCount++;
266 return nCount;
267}

◆ splice()

void LIST_T::splice ( Iterator _pos,
LIST_T & _other,
Iterator _otherFirst,
Iterator _otherLast )

Definition at line 249 of file __LIST.cpp.

251{
252 size_t nMoveCount = size((ListNode*)(_otherFirst.__pNode),
253 (ListNode*)(_otherLast.__pNode));
254 __size += nMoveCount;
255 _other.__size -= nMoveCount;
256
257 move(_pos, _otherFirst, _otherLast);
258}
void move(Iterator posTo, Iterator _first, Iterator _last)
Definition __LIST.cpp:233
size_t size() const
Definition __LIST.h:569

Member Data Documentation

◆ __pMasterNode

NodeBase* LIST_T::__pMasterNode
protected

Definition at line 169 of file __LIST.h.

◆ __size

size_t LIST_T::__size
protected

Definition at line 170 of file __LIST.h.


The documentation for this class was generated from the following files: