Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FaceList.cpp
Go to the documentation of this file.
1 
2 #include "FaceList.hpp"
3 
4 
6  d_first(0),
7  d_current(0),
8  d_size(0) {}
9 
10 FaceList::FaceList( const FaceList& 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 FaceList::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  }
28 }
29 
30 
32  if( d_first ) delete d_first;
33 }
34 
35 const FaceList& FaceList::operator=( const FaceList& 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 FaceList::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  }
55  return *this;
56 }
57 
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 FaceList::Elem( val );
68  }
69  else {
70  d_first = new Elem( val );
72  }
73  d_size++;
74 }
75 
77  Face* 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 ){
89  }
90  else {
91  bef->d_next = d_current->d_next;
92  }
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 FaceList::move_to(Face* val){
103  d_current = d_first;
104  while( d_current && d_current->d_val != val ){
106  }
107  return( d_current ? TRUE : FALSE );
108 }
109 
110 int FaceList::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 FaceList::index( int ind ){
122 
123  d_current = d_first;
124  int i;
125  for( i = 0; i < ind; i++ ){
127  }
128 }
129 
130 
#define FALSE
Definition: vinci.h:133
const FaceList & operator=(const FaceList &olist)
Definition: FaceList.cpp:35
Elem * d_next
Definition: FaceList.hpp:37
int index() const
Definition: FaceList.cpp:110
FaceList()
Definition: FaceList.cpp:5
Elem * d_current
Definition: FaceList.hpp:49
blockLoc i
Definition: read.cpp:79
Face * d_val
Definition: FaceList.hpp:36
#define TRUE
Definition: vinci.h:134
Face * remove()
Definition: FaceList.cpp:76
void append(Face *val)
Definition: FaceList.cpp:58
~FaceList()
Definition: FaceList.cpp:31
Elem * d_first
Definition: FaceList.hpp:48
boolean move_to(Face *val)
Definition: FaceList.cpp:102
int d_size
Definition: FaceList.hpp:51
The Face class is an abstract base class that supplies implemented general methods, as well as a vew virtual interface methods to child classes.
Definition: Face.hpp:19