VR-Forces Development_Version Class Documentation
Home
Modules
Namespaces
Classes
Files
Examples
Behavior Models
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
include
gdb
simpleList.h
Go to the documentation of this file.
1
/*********************************************************************
2
** Copyright (c) 1999 MaK Technologies, Inc.
3
** All rights reserved.
4
*********************************************************************/
5
/*********************************************************************
6
** $RCSfile: slList.h,v $ $Revision: 1.7 $ $State: Exp $
7
*********************************************************************/
8
9
#ifndef simpleList_H_
10
#define simpleList_H_
11
12
#include "
gdb/gdbDefines.h
"
13
#include <vlutil/vlMachineTypes.h>
14
15
//forward declaration
16
class
DtSimpleListItem
;
17
18
// class DtSimpleList:
19
//
20
// DtSimpleList is fashioned after DtList in VR-Link. However, it provides
21
// a singly-linked list for situations where a simple traversal of the
22
// list is all that is required.
23
// @note This class has no virtual functions on purpose to reduce the size
24
// of the items as DtGroups use DtSimpleLists to hold their children, which
25
// means at least one DtSimpleList for every type of group node in the
26
// scene, which adds up for large scenes. Additionally, other classes should
27
// @b not be derived from this class as it is just a container.
28
//
29
class
DT_DLL_gdb
DtSimpleList
30
{
31
public
:
32
33
// constructor
34
DtSimpleList
();
35
36
// destructor
37
// Note: ~DtSimpleList() does not free memory of data associated
38
// with the items. It only frees the items.
39
~
DtSimpleList
();
40
41
// returns first item on list
42
DtSimpleListItem
* first()
const
;
43
44
// returns last item on list
45
DtSimpleListItem
* last()
const
;
46
47
// returns size of list
48
unsigned
int
count()
const
;
49
50
// add an element to the end of the list
51
DtSimpleListItem
* add(
void
* data);
52
53
// add an element to the beginning of the list
54
DtSimpleListItem
* addToStart(
void
* data);
55
56
// add an element to the end of the list
57
DtSimpleListItem
* addToEnd(
void
* data);
58
59
// add an element with specified data component to list, appearing
60
// immediately after list element specified as 'after'
61
DtSimpleListItem
* addAfter(
void
* data,
DtSimpleListItem
* after);
62
63
// Note: remove does not free memory of data associated
64
// with the item. It only frees the item. The data is
65
// returned to the caller for deletion if required.
66
void
*
remove
(
DtSimpleListItem
* item);
67
68
69
// Does NOT delete the data in the list. Merely removes the data
70
// from the list. Data must be deleted later.
71
void
removeAll();
72
73
// return list element whose data component is as specified.
74
DtSimpleListItem
* itemLookup(
void
* data)
const
;
75
76
// The sort method sorts the items according to a user-defined comparison
77
// function. If the comparison function is compare(), then compare(e1,e2)
78
// should return an int value <0 if e1<e2, 0 if e1=e2, and >0 if e1>e2.
79
// The parameters e1 and e2 are void pointers to raw data type.
80
// The items are sorted in increasing order.
81
82
void
sort(
int
(* compare)(
const
void
*e1,
const
void
*e2));
83
84
// If a copy constructor is implemented, the assignment operator should
85
// also be implemented. Should generally implement both of them anyway to
86
// avoid memory problems due to inappropriate compiler provided defaults.
87
// Access varies so need to put proper access keyword above these
88
// declarations.
89
90
// copy constructor
91
DtSimpleList
(
const
DtSimpleList
& orig);
92
93
// assignment operator
94
DtSimpleList
& operator=(
const
DtSimpleList
& orig);
95
96
97
protected
:
98
99
// add list item to appear immediately after list item 'after'
100
void
addToList(
DtSimpleListItem
* item,
DtSimpleListItem
* after);
101
102
// remove specified item from list
103
void
removeFromList(
DtSimpleListItem
* item);
104
105
protected
:
106
107
DtSimpleListItem
*
myFirst
;
108
DtSimpleListItem
*
myLast
;
109
unsigned
int
myCount
;
110
111
};
112
113
114
inline
DtSimpleListItem
*
DtSimpleList::first
()
const
115
{
116
return
myFirst
;
117
}
118
119
inline
DtSimpleListItem
*
DtSimpleList::last
()
const
120
{
121
return
myLast
;
122
}
123
124
inline
unsigned
int
DtSimpleList::count
()
const
125
{
126
return
myCount
;
127
}
128
129
// add an element to the end of the list
130
inline
DtSimpleListItem
*
DtSimpleList::add
(
void
* data)
131
{
132
return
addAfter
(data,
myLast
);
133
}
134
135
// add an elemnt to the beginning of the list
136
inline
DtSimpleListItem
*
DtSimpleList::addToStart
(
void
* data)
137
{
138
return
addAfter
(data, 0);
139
}
140
141
// add an element to the end of the list
142
inline
DtSimpleListItem
*
DtSimpleList::addToEnd
(
void
* data)
143
{
144
return
addAfter
(data,
myLast
);
145
}
146
147
#endif
Document ID: Generated on Mon Jul 4 01:00:18 EDT 2016 from SVN revision 166489
Copyright © 2005-2015 VT MÄK. All Rights Reserved (
www.mak.com
)