Rocstar
1.0
Rocstar multiphysics simulation application
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
NodeList.cpp
Go to the documentation of this file.
1
2
#include "
NodeList.hpp
"
3
4
5
NodeList::NodeList
() :
6
d_first(0),
7
d_current(0),
8
d_size(0) {}
9
10
NodeList::NodeList
(
const
NodeList
& olist) :
11
d_size(olist.d_size) {
12
13
// just add all the list
14
Elem
* oval = olist.
d_first
;
15
Elem
* prev(0);
16
while
( oval ){
17
Elem
*nelem =
new
NodeList::Elem
( oval->
d_val
);
18
if
( prev ){
19
prev->
d_next
= nelem;
20
}
21
else
{
22
d_first
= nelem;
23
}
24
prev = nelem;
25
oval = oval->
d_next
;
26
}
27
d_current
=
d_first
;
28
}
29
30
31
NodeList::~NodeList
() {
32
if
(
d_first
)
delete
d_first
;
33
}
34
35
const
NodeList
&
NodeList::operator=
(
const
NodeList
& olist){
36
37
if
(
d_first
)
delete
d_first
;
38
39
d_size
= olist.
d_size
;
40
// just add all the list
41
Elem
* oval = olist.
d_first
;
42
Elem
* prev(0);
43
while
( oval ){
44
Elem
*nelem =
new
NodeList::Elem
( oval->
d_val
);
45
if
( prev ){
46
prev->
d_next
= nelem;
47
}
48
else
{
49
d_first
= nelem;
50
}
51
prev = nelem;
52
oval = oval->
d_next
;
53
}
54
d_current
=
d_first
;
55
return
*
this
;
56
}
57
58
void
NodeList::append
(
Node
* val){
59
60
Elem
* bef(0);
61
Elem
* af(
d_first
);
62
while
( af ){
63
bef = af;
64
af = af->
d_next
;
65
}
66
if
( bef ){
67
bef->
d_next
=
new
NodeList::Elem
( val );
68
}
69
else
{
70
d_first
=
new
Elem
( val );
71
d_current
=
d_first
;
72
}
73
d_size
++;
74
}
75
76
Node
*
NodeList::remove
(){
77
Node
* val =
d_current
->
d_val
;
78
79
d_size
--;
80
81
Elem
* bef(0);
82
Elem
* af(
d_first
);
83
while
( af !=
d_current
){
84
bef = af;
85
af = af->
d_next
;
86
}
87
if
( !bef ){
88
d_first
=
d_current
->
d_next
;
89
}
90
else
{
91
bef->
d_next
=
d_current
->
d_next
;
92
}
93
d_current
=
d_current
->
d_next
;
94
af->
d_next
= 0;
95
delete
af;
// the old current - remove only it
96
if
( !
d_current
)
d_current
=
d_first
;
97
return
val;
98
}
99
100
101
102
boolean
NodeList::move_to
(
Node
* val){
103
d_current
=
d_first
;
104
while
(
d_current
&&
d_current
->
d_val
!= val ){
105
d_current
=
d_current
->
d_next
;
106
}
107
return
(
d_current
?
TRUE
:
FALSE
);
108
}
109
110
int
NodeList::index
()
const
{
111
112
int
ind = 0;
113
Elem
* pass =
d_first
;
114
while
( pass !=
d_current
){
115
ind++;
116
pass = pass->
d_next
;
117
}
118
return
ind;
119
}
120
121
void
NodeList::index
(
int
ind ){
122
123
d_current
=
d_first
;
124
int
i
;
125
for
( i = 0; i < ind; i++ ){
126
d_current
=
d_current
->
d_next
;
127
}
128
}
129
130
NodeList
Definition:
NodeList.hpp:7
FALSE
#define FALSE
Definition:
vinci.h:133
NodeList::~NodeList
~NodeList()
Definition:
NodeList.cpp:31
Node
This class encapsulate a node over a window manifold.
Definition:
Manifold_2.h:370
NodeList::operator=
const NodeList & operator=(const NodeList &olist)
Definition:
NodeList.cpp:35
NodeList::Elem::d_val
Node * d_val
Definition:
NodeList.hpp:36
NodeList::Elem::d_next
Elem * d_next
Definition:
NodeList.hpp:37
NodeList::Elem
Definition:
NodeList.hpp:35
NodeList.hpp
i
blockLoc i
Definition:
read.cpp:79
TRUE
#define TRUE
Definition:
vinci.h:134
NodeList::d_first
Elem * d_first
Definition:
NodeList.hpp:48
NodeList::append
void append(Node *val)
Definition:
NodeList.cpp:58
NodeList::index
int index() const
Definition:
NodeList.cpp:110
NodeList::d_current
Elem * d_current
Definition:
NodeList.hpp:49
NodeList::remove
Node * remove()
Definition:
NodeList.cpp:76
NodeList::NodeList
NodeList()
Definition:
NodeList.cpp:5
NodeList::d_size
int d_size
Definition:
NodeList.hpp:51
NodeList::move_to
boolean move_to(Node *val)
Definition:
NodeList.cpp:102
Rocfrac
utilities
CohIn
NodeList.cpp
Generated on Wed Nov 30 2016 16:56:10 for Rocstar by
1.8.5