VR-Link API Documentation for DIS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vlList.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 1992-2010 VT MAK
3 ** All rights reserved.
4 *********************************************************************/
8 #pragma once
9 
11 #include "vlMachineTypes.h"
12 #include <stddef.h>
13 
14 #ifdef DtUSE_UTILITIES_NAMESPACE
15 namespace DtUSE_UTILITIES_NAMESPACE
16 {
17 #endif
18 
26 {
27 public:
28 
29  friend class DtList;
30 
31 public:
32 
34  virtual ~DtListItem();
35 
38  DtListItem* prev() const;
39  DtListItem* next() const;
40 
42  void* data() const;
43 
44 protected:
45 
47  DtListItem(void* d);
48 
49 protected:
50 
53  void* myData;
54 };
55 
72 {
73 
74 public:
75 
77  DtList();
78 
81  virtual ~DtList();
82 
85  DtList(const DtList& orig);
86 
91  DtList& operator=(const DtList& orig);
92 
95  DtListItem* first() const;
96  DtListItem* last() const;
97 
99  unsigned count() const;
100 
103  DtListItem* add(void* data);
104 
107  DtListItem* addToStart(void* data);
108 
111  DtListItem* addToEnd(void* data);
112 
115  DtListItem* addBefore (void* data, DtListItem* before);
116 
119  DtListItem* addAfter(void* data, DtListItem* after);
120 
126  void* remove(DtListItem* item);
127 
130  void removeAll();
131 
134  DtListItem* itemLookup(const void* data) const;
135 
136 protected:
137 
139  virtual void addToList(DtListItem* item, DtListItem* after);
140 
143  virtual void removeFromList(DtListItem* item);
144 
145 protected:
146 
149  unsigned myCount;
150 };
151 
152 
157 
159 {
160 public:
161 
162  friend class DtIntrusiveList;
163 
164 public:
165 
167  DtListedObj();
168 
170  virtual ~DtListedObj();
171 
174  void* next() const;
175  void* prev() const;
176 
180  void* wrapNext() const;
181  void* wrapPrev() const;
182 
183 protected:
184 
187 };
188 
189 
195 
197 {
198 protected:
199 
202  virtual void addToList(DtListItem* item, DtListItem* after);
203 
206  virtual void removeFromList(DtListItem* item);
207 
209  void removeAndDelete(const DtListedObj* data);
210 
213  virtual void removeAndDelete(DtListItem* item);
214 
216  virtual void removeAllAndDelete();
217 };
218 
220 
221 inline DtListItem* DtListItem::prev() const
222 {
223  return myPrev;
224 }
225 
226 inline DtListItem* DtListItem::next() const
227 {
228  return myNext;
229 }
230 
231 inline void* DtListItem::data() const
232 {
233  return myData;
234 }
235 
236 inline DtListItem* DtList::first() const
237 {
238  return myFirst;
239 }
240 
241 inline DtListItem* DtList::last() const
242 {
243  return myLast;
244 }
245 
246 inline unsigned DtList::count() const
247 {
248  return myCount;
249 }
250 
251 inline DtListItem* DtList::add(void* data)
252 {
253  return addAfter(data, myLast);
254 }
255 
256 inline DtListItem* DtList::addToStart(void* data)
257 {
258  return addAfter(data, 0);
259 }
260 
261 inline DtListItem* DtList::addToEnd(void* data)
262 {
263  return addAfter(data, myLast);
264 }
265 /*lint -save -e818 */
266 inline DtListItem* DtList::addBefore (void* data, DtListItem* before)
267 {
268  return addAfter(data, before ? before->myPrev : (DtListItem*) 0);
269 }
270 /*lint -restore */
271 
272 inline void* DtListedObj::next() const
273 {
274  return (myItem && myItem->next()) ? myItem->next()->data() : 0;
275 }
276 
277 inline void* DtListedObj::prev() const
278 {
279  return (myItem && myItem->prev()) ? myItem->prev()->data() : 0;
280 }
281 
282 inline void* DtListedObj::wrapNext() const
283 {
284  return next() ? next() :
285  ((myList && myList->first()) ? myList->first()->data() : 0);
286 }
287 
288 inline void* DtListedObj::wrapPrev() const
289 {
290  return prev() ? prev() :
291  ((myList && myList->last()) ? myList->last()->data() : 0);
292 }
293 
295 #define looplist(theData, list) \
296 for (DtListItem* item=(list)->first(); \
297  theData = (item ? item->data() : 0); \
298  item = item->next())
299 
302 #define looptlist(theData, type, list) \
303 for (DtListItem* item=(list)->first(); \
304  theData = (type)(item ? item->data() : 0); \
305  item = item->next())
306 
309 #define looptlist2(theData, type, list) \
310 for (item=(list)->first(); \
311  theData = (type)(item ? item->data() : 0); \
312  item = item->next())
313 
314 #ifdef DtUSE_UTILITIES_NAMESPACE
315 }
316 #endif
317 
DtListItem * first() const
Return first and last item on the list.
Definition: vlList.h:236
void * next() const
Return next (previous) elements on the list, or NULL if hit the end (beginning) of the list...
Definition: vlList.h:272
DtListItem * myPrev
Definition: vlList.h:51
unsigned myCount
Definition: vlList.h:149
DtListItem * add(void *data)
Add element to the end of the list.
Definition: vlList.h:251
DtListItem * prev() const
Return previous (next) item.
Definition: vlList.h:221
DtListItem * myFirst
Definition: vlList.h:147
DtListItem * myLast
Definition: vlList.h:148
An intrusive list is a list that assumes that the elements that you add are pointers to instances of ...
Definition: vlList.h:196
DtListItem * addToStart(void *data)
Add element to the beginning of the list.
Definition: vlList.h:256
DtList * myList
Definition: vlList.h:185
DtList is deprecated, please use std::list&lt;T&gt;.
Definition: vlList.h:71
void * prev() const
Definition: vlList.h:277
void * wrapNext() const
Return next (previous) elements on the list, but wrap to the beginning (end) of the list when you hit...
Definition: vlList.h:282
DtListItem * myNext
Definition: vlList.h:52
This is a base class from which elements of a DtIntrusiveList must be derived.
Definition: vlList.h:158
DtListItem * next() const
Definition: vlList.h:226
DtListItem * myItem
Definition: vlList.h:186
unsigned count() const
Returns the number of elements in the list.
Definition: vlList.h:246
DtListItem * last() const
Definition: vlList.h:241
void * wrapPrev() const
Definition: vlList.h:288
lint -e266
Definition: vlList.h:25
void * data() const
Returns the data element contained in the DtListItem envelope.
Definition: vlList.h:231
DtListItem * addToEnd(void *data)
Add element to the end of the list.
Definition: vlList.h:261
void * myData
Definition: vlList.h:53
DtListItem * addBefore(void *data, DtListItem *before)
Add element to the list just before the indicated item.
Definition: vlList.h:266
This file contains typedefs for machine dependant types.
#define DT_DLL_VLUTIL
Definition: vlMachineTypes.h:109

Document ID: Generated on Tue Feb 2 21:02:17 EST 2021 from SVN revision 223668
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)