Rocstar
1.0
Rocstar multiphysics simulation application
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
ElementList.cpp
Go to the documentation of this file.
1
2
#include "
ElementList.hpp
"
3
4
5
ElementList::ElementList
() :
6
d_first(0),
7
d_current(0),
8
d_size(0) {}
9
10
ElementList::ElementList
(
const
ElementList
& 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
ElementList::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
ElementList::~ElementList
() {
32
if
(
d_first
)
delete
d_first
;
33
}
34
35
const
ElementList
&
ElementList::operator=
(
const
ElementList
& 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
ElementList::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
ElementList::append
(
Element
* 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
ElementList::Elem
( val );
68
}
69
else
{
70
d_first
=
new
Elem
( val );
71
d_current
=
d_first
;
72
}
73
d_size
++;
74
}
75
76
Element
*
ElementList::remove
(){
77
Element
* 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
ElementList::move_to
(
Element
* 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
ElementList::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
ElementList::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
FALSE
#define FALSE
Definition:
vinci.h:133
ElementList
Definition:
ElementList.hpp:7
ElementList::Elem
Definition:
ElementList.hpp:35
ElementList::ElementList
ElementList()
Definition:
ElementList.cpp:5
ElementList::operator=
const ElementList & operator=(const ElementList &olist)
Definition:
ElementList.cpp:35
ElementList::Elem::d_val
Element * d_val
Definition:
ElementList.hpp:36
i
blockLoc i
Definition:
read.cpp:79
TRUE
#define TRUE
Definition:
vinci.h:134
ElementList::d_first
Elem * d_first
Definition:
ElementList.hpp:48
Element
Definition:
Element.hpp:12
ElementList::remove
Element * remove()
Definition:
ElementList.cpp:76
ElementList::~ElementList
~ElementList()
Definition:
ElementList.cpp:31
ElementList::index
int index() const
Definition:
ElementList.cpp:110
ElementList::Elem::d_next
Elem * d_next
Definition:
ElementList.hpp:37
ElementList::d_current
Elem * d_current
Definition:
ElementList.hpp:49
ElementList::move_to
boolean move_to(Element *val)
Definition:
ElementList.cpp:102
ElementList.hpp
ElementList::d_size
int d_size
Definition:
ElementList.hpp:51
ElementList::append
void append(Element *val)
Definition:
ElementList.cpp:58
Rocfrac
utilities
CohIn
ElementList.cpp
Generated on Wed Nov 30 2016 16:56:06 for Rocstar by
1.8.5