Rocstar
1.0
Rocstar multiphysics simulation application
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
IntList.cpp
Go to the documentation of this file.
1
2
#include "
IntList.hpp
"
3
4
IntList::IntList
() :
5
d_first(0),
6
d_current(0),
7
d_size(0) {}
8
9
IntList::IntList
(
const
IntList
& olist) :
10
d_size(olist.d_size) {
11
12
// just add all the list
13
Elem
* oelem = olist.
d_first
;
14
Elem
* prev(0);
15
while
( oelem ){
16
Elem
*nelem =
new
IntList::Elem
( oelem->
d_val
);
17
if
( prev ){
18
prev->
d_next
= nelem;
19
}
20
else
{
21
d_first
= nelem;
22
}
23
prev = nelem;
24
oelem = oelem->
d_next
;
25
}
26
d_current
=
d_first
;
27
}
28
29
30
IntList::~IntList
() {
31
if
(
d_first
)
delete
d_first
;
32
}
33
34
const
IntList
&
IntList::operator=
(
const
IntList
& olist){
35
36
if
(
d_first
)
delete
d_first
;
37
38
d_size
= olist.
d_size
;
39
// just add all the list
40
Elem
* oelem = olist.
d_first
;
41
Elem
* prev(0);
42
while
( oelem ){
43
Elem
*nelem =
new
IntList::Elem
( oelem->
d_val
);
44
if
( prev ){
45
prev->
d_next
= nelem;
46
}
47
else
{
48
d_first
= nelem;
49
}
50
prev = nelem;
51
oelem = oelem->
d_next
;
52
}
53
d_current
=
d_first
;
54
return
*
this
;
55
}
56
57
void
IntList::append
(
int
val){
58
59
Elem
* bef(0);
60
Elem
* af(
d_first
);
61
while
( af ){
62
bef = af;
63
af = af->
d_next
;
64
}
65
if
( bef ){
66
bef->
d_next
=
new
IntList::Elem
( val );
67
}
68
else
{
69
d_first
=
new
Elem
( val );
70
d_current
=
d_first
;
71
}
72
d_size
++;
73
}
74
75
int
IntList::remove
(){
76
77
int
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
IntList::move_to
(
int
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
IntList::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
IntList::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
IntList::d_first
Elem * d_first
Definition:
IntList.hpp:48
IntList::Elem::d_next
Elem * d_next
Definition:
IntList.hpp:37
IntList::IntList
IntList()
Definition:
IntList.cpp:4
IntList::move_to
boolean move_to(int ed)
Definition:
IntList.cpp:102
IntList::~IntList
~IntList()
Definition:
IntList.cpp:30
IntList::d_current
Elem * d_current
Definition:
IntList.hpp:49
IntList::Elem::d_val
int d_val
Definition:
IntList.hpp:36
IntList.hpp
IntList::remove
int remove()
Definition:
IntList.cpp:75
IntList
Definition:
IntList.hpp:7
i
blockLoc i
Definition:
read.cpp:79
TRUE
#define TRUE
Definition:
vinci.h:134
IntList::operator=
const IntList & operator=(const IntList &olist)
Definition:
IntList.cpp:34
IntList::d_size
int d_size
Definition:
IntList.hpp:51
IntList::append
void append(int ed)
Definition:
IntList.cpp:57
IntList::index
int index() const
Definition:
IntList.cpp:110
IntList::Elem
Definition:
IntList.hpp:35
Rocfrac
utilities
CohIn
IntList.cpp
Generated on Wed Nov 30 2016 16:56:08 for Rocstar by
1.8.5