DCL 4.0
Loading...
Searching...
No Matches
__LIST.h
Go to the documentation of this file.
1#ifdef __DCL_INTERNAL__
2
3#ifdef __COMPILE_StringList__
4 #define THIS_NAME __szStringList_h__
5 #define THIS_VALUE __T("dcl/__LIST.h/String")
6 #define LIST_T StringList
7 #define ELEMENT_T String
8 #define ELEMENT_T_CAST
9 #define CONST_ELEMENT_REF const String&
10 #define HAVE_CONSTRUCTOR_ELEMENT 1
11#elif defined(__COMPILE_ByteStringList__)
12 #define THIS_NAME __szByteStringList_h__
13 #define THIS_VALUE __T("dcl/__LIST.h/ByteString")
14 #define LIST_T ByteStringList
15 #define ELEMENT_T ByteString
16 #define ELEMENT_T_CAST
17 #define CONST_ELEMENT_REF const ByteString&
18 #define HAVE_CONSTRUCTOR_ELEMENT 1
19#elif defined(__COMPILE_PointerList__)
20 #define THIS_NAME __szPointerList_h__
21 #define THIS_VALUE __T("dcl/__LIST.h/void*")
22 #define LIST_T PointerList
23 #define ELEMENT_T void*
24 #define ELEMENT_T_CAST (void*)
25 #define CONST_ELEMENT_REF const void*
26 #define HAVE_CONSTRUCTOR_ELEMENT 0
27#endif
28
29#if __DCL_HAVE_THIS_FILE__
30 static const char_t THIS_NAME[] = THIS_VALUE;
31 #undef __THIS_FILE__
32 #define __THIS_FILE__ THIS_NAME
33#endif
34
50
51class DCLCAPI LIST_T : public Object
52{
54public:
55 virtual String toString() const;
56
57public:
58 struct ListNode : public NodeBase
59 {
60 ELEMENT_T data;
61 };
62
63 class ConstIterator;
65 {
66 public:
67 Iterator();
68 Iterator(NodeBase* _pNode);
69 Iterator(const Iterator& _it);
70 Iterator& operator=(const Iterator& _it);
75 ELEMENT_T& operator*();
76
77 protected:
78 friend class LIST_T;
79 friend class ConstIterator;
80 };
81
83 {
84 public:
86 ConstIterator(const NodeBase* _pNode);
87 ConstIterator(const ConstIterator& _it);
88 ConstIterator(const Iterator& _it);
94 CONST_ELEMENT_REF operator*();
95 };
96
99 {
100 public:
102 ReverseIterator(NodeBase* _pNode);
109 ELEMENT_T& operator*();
110
111 protected:
112 friend class LIST_T;
114 };
115
130
131public:
132 virtual ~LIST_T();
133 LIST_T();
134 LIST_T(const LIST_T& _src);
135 const LIST_T& operator=(const LIST_T& _src);
136
137 ConstIterator begin() const;
138 ConstIterator end() const;
139 Iterator begin();
140 Iterator end();
141
146
147 // return is current Iterator
148 Iterator insert(Iterator _pos, CONST_ELEMENT_REF _element);
149 void insert(Iterator _pos, ConstIterator _first, ConstIterator _last);
150
151 Iterator find(CONST_ELEMENT_REF _element);
152
153 // return is next Iterator
154 Iterator erase(Iterator _pos);
155 void splice(Iterator _pos, LIST_T& _other, Iterator _otherFirst, Iterator _otherLast);
156
157 LIST_T& add(CONST_ELEMENT_REF _element);
158 LIST_T& addHead(CONST_ELEMENT_REF _element);
159 LIST_T& addTail(CONST_ELEMENT_REF _element);
160
161 ELEMENT_T removeHead();
162 ELEMENT_T removeTail();
163
164 void clear();
165 bool isEmpty() const;
166 size_t size() const;
167
168protected:
170 size_t __size;
171
172 size_t size(ConstIterator _first, ConstIterator _last) const;
173 // _first ~ _last to posTo
174 void move(Iterator posTo, Iterator _first, Iterator _last);
175
176 ListNode* createNode(CONST_ELEMENT_REF _element);
177 void destroyNode(ListNode* _pNode);
178};
179
181
182inline
187
188inline
190{
191 __DCL_ASSERT(_pNode != NULL);
192 __pNode = _pNode;
193}
194
195inline
197{
198 __DCL_ASSERT(_it.__pNode != NULL);
199 __pNode = _it.__pNode;
200}
201
202inline
205{
206 __DCL_ASSERT(_it.__pNode != NULL);
207 __pNode = _it.__pNode;
208 return *this;
209}
210
211inline
214{
216 __pNode = __pNode->pNext;
217 return *this;
218}
219
220inline
223{
225 NodeBase* pSaveNode = __pNode;
226 __pNode = __pNode->pNext;
227 return Iterator(pSaveNode);
228}
229
230inline
233{
235 __pNode = __pNode->pPrev;
236 return *this;
237}
238
239inline
242{
244 NodeBase* pSaveNode = __pNode;
245 __pNode = __pNode->pPrev;
246 return Iterator(pSaveNode);
247}
248
249inline
250ELEMENT_T&
252{
254 return ((ListNode*)__pNode)->data;
255}
256
258
259inline
264
265inline
267{
268 __DCL_ASSERT(_pNode != NULL);
269 __pNode = _pNode;
270}
271
272inline
278
279inline
285
286inline
289{
290 __DCL_ASSERT(_it.__pNode != NULL);
291 __pNode = _it.__pNode;
292 return *this;
293}
294
295inline
298{
300 __pNode = __pNode->pNext;
301 return *this;
302}
303
304inline
307{
309 const NodeBase* pSaveNode = __pNode;
310 __pNode = __pNode->pNext;
311 return ConstIterator(pSaveNode);
312}
313
314inline
317{
319 __pNode = __pNode->pPrev;
320 return *this;
321}
322
323inline
326{
328 const NodeBase* pSaveNode = __pNode;
329 __pNode = __pNode->pPrev;
330 return ConstIterator(pSaveNode);
331}
332
333inline
334CONST_ELEMENT_REF
340
342
343inline
348
349inline
351{
352 __DCL_ASSERT(_pNode != NULL);
353 __pNode = _pNode;
354}
355
356inline
362
363inline
366{
367 __DCL_ASSERT(_it.__pNode != NULL);
368 __pNode = _it.__pNode;
369 return *this;
370}
371
372inline
375{
377 __pNode = __pNode->pPrev;
378 return *this;
379}
380
381inline
384{
386 NodeBase* pSaveNode = __pNode;
387 __pNode = __pNode->pPrev;
388 return ReverseIterator(pSaveNode);
389}
390
391inline
394{
396 __pNode = __pNode->pNext;
397 return *this;
398}
399
400inline
403{
405 NodeBase* pSaveNode = __pNode;
406 __pNode = __pNode->pNext;
407 return ReverseIterator(pSaveNode);
408}
409
410inline
411ELEMENT_T&
417
419
420inline
425
426inline
428{
429 __DCL_ASSERT(_pNode != NULL);
430 __pNode = _pNode;
431}
432
433inline
439
440inline
446
447inline
450{
451 __DCL_ASSERT(_it.__pNode != NULL);
452 __pNode = _it.__pNode;
453 return *this;
454}
455
456inline
459{
461 __pNode = __pNode->pPrev;
462 return *this;
463}
464
465inline
468{
470 const NodeBase* pSaveNode = __pNode;
471 __pNode = __pNode->pPrev;
472 return ReverseConstIterator(pSaveNode);
473}
474
475inline
478{
480 __pNode = __pNode->pNext;
481 return *this;
482}
483
484inline
487{
489 const NodeBase* pSaveNode = __pNode;
490 __pNode = __pNode->pNext;
491 return ReverseConstIterator(pSaveNode);
492}
493
494inline
495CONST_ELEMENT_REF
501
503
504inline
507{
508 return __pMasterNode->pNext;
509}
510
511inline
514{
515 return __pMasterNode;
516}
517
518inline
521{
522 return __pMasterNode->pNext;
523}
524
525inline
528{
529 return __pMasterNode;
530}
531
532inline
535{
536 return __pMasterNode->pPrev;
537}
538
539inline
542{
543 return __pMasterNode;
544}
545
546inline
549{
550 return __pMasterNode->pPrev;
551}
552
553inline
556{
557 return __pMasterNode;
558}
559
560inline
561bool
563{
564 return __pMasterNode->pNext == __pMasterNode;
565}
566
567inline
568size_t
570{
571 return __size;
572}
573
574inline
575LIST_T&
576LIST_T::addHead(CONST_ELEMENT_REF _element)
577{
578 insert(begin(), _element);
579 return *this;
580}
581
582inline
583LIST_T&
584LIST_T::addTail(CONST_ELEMENT_REF _element)
585{
586 insert(end(), _element);
587 return *this;
588}
589
590inline
591LIST_T&
592LIST_T::add(CONST_ELEMENT_REF _element)
593{
594 insert(end(), _element);
595 return *this;
596}
597
598#if __DCL_HAVE_THIS_FILE__
599 #undef __THIS_FILE__
600 #define __THIS_FILE__ __T(__FILE__)
601#endif
602
603#undef THIS_NAME
604#undef THIS_VALUE
605#undef LIST_T
606#undef ELEMENT_T
607#undef ELEMENT_T_CAST
608#undef CONST_ELEMENT_REF
609#undef HAVE_CONSTRUCTOR_ELEMENT
610
611#endif // __DCL_INTERNAL__
#define NULL
Definition Config.h:340
#define DCLCAPI
Definition Config.h:100
wchar_t char_t
Definition Config.h:275
#define DECLARE_CLASSINFO(class_name)
Definition Object.h:210
#define __DCL_ASSERT(expr)
Definition Object.h:371
void CharsetConvertException *__fields clear()
const NodeBase * __pNode
Definition ListBase.h:44
ConstIterator & operator++()
Definition __LIST.h:297
ConstIterator & operator=(const ConstIterator &_it)
Definition __LIST.h:288
ConstIterator & operator--()
Definition __LIST.h:316
CONST_ELEMENT_REF operator*()
Definition __LIST.h:335
ELEMENT_T & operator*()
Definition __LIST.h:251
Iterator & operator--()
Definition __LIST.h:232
friend class ConstIterator
Definition __LIST.h:79
Iterator & operator=(const Iterator &_it)
Definition __LIST.h:204
Iterator & operator++()
Definition __LIST.h:213
friend class LIST_T
Definition __LIST.h:78
CONST_ELEMENT_REF operator*()
Definition __LIST.h:496
ReverseConstIterator & operator++()
Definition __LIST.h:458
ReverseConstIterator & operator--()
Definition __LIST.h:477
ReverseConstIterator & operator=(const ReverseConstIterator &_it)
Definition __LIST.h:449
ReverseIterator & operator--()
Definition __LIST.h:393
friend class ReverseConstIterator
Definition __LIST.h:113
ReverseIterator & operator=(const ReverseIterator &_it)
Definition __LIST.h:365
ReverseIterator & operator++()
Definition __LIST.h:374
friend class LIST_T
Definition __LIST.h:112
ELEMENT_T & operator*()
Definition __LIST.h:412
ListNode * createNode(CONST_ELEMENT_REF _element)
Definition __LIST.cpp:117
LIST_T & add(CONST_ELEMENT_REF _element)
Definition __LIST.h:592
LIST_T()
Definition __LIST.cpp:76
LIST_T & addHead(CONST_ELEMENT_REF _element)
Definition __LIST.h:576
void move(Iterator posTo, Iterator _first, Iterator _last)
Definition __LIST.cpp:233
ReverseConstIterator rend() const
Definition __LIST.h:541
void destroyNode(ListNode *_pNode)
Definition __LIST.cpp:141
void splice(Iterator _pos, LIST_T &_other, Iterator _otherFirst, Iterator _otherLast)
Definition __LIST.cpp:249
virtual ~LIST_T()
ConstIterator end() const
Definition __LIST.h:513
ELEMENT_T removeHead()
Definition __LIST.cpp:214
const LIST_T & operator=(const LIST_T &_src)
Definition __LIST.cpp:105
Iterator find(CONST_ELEMENT_REF _element)
Definition __LIST.cpp:173
Iterator erase(Iterator _pos)
Definition __LIST.cpp:201
LIST_T & addTail(CONST_ELEMENT_REF _element)
Definition __LIST.h:584
ELEMENT_T removeTail()
Definition __LIST.cpp:223
ReverseConstIterator rbegin() const
Definition __LIST.h:534
ConstIterator begin() const
Definition __LIST.h:506
size_t size() const
Definition __LIST.h:569
bool isEmpty() const
Definition __LIST.h:562
NodeBase * __pMasterNode
Definition __LIST.h:169
size_t __size
Definition __LIST.h:170
Iterator insert(Iterator _pos, CONST_ELEMENT_REF _element)
Definition __LIST.cpp:150
NodeBase * __pNode
Definition ListBase.h:30
Object()
Definition Object.cpp:183
virtual String toString() const
Definition Object.cpp:187
ELEMENT_T data
Definition __LIST.h:60