Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IntList Class Reference

#include <IntList.hpp>

Collaboration diagram for IntList:

Classes

struct  Elem
 

Public Member Functions

 IntList ()
 
 IntList (const IntList &olist)
 
 ~IntList ()
 
const IntListoperator= (const IntList &olist)
 
void append (int ed)
 
void insert (int ed)
 
void insert_first (int ed)
 
void reset ()
 
void next ()
 
int & get ()
 
int remove ()
 
boolean empty ()
 
int size ()
 
boolean move_to (int ed)
 
int index () const
 
void index (int ind)
 

Private Attributes

Elemd_first
 
Elemd_current
 
int d_size
 

Detailed Description

Definition at line 7 of file IntList.hpp.

Constructor & Destructor Documentation

IntList ( )

Definition at line 4 of file IntList.cpp.

4  :
5  d_first(0),
6  d_current(0),
7  d_size(0) {}
Elem * d_first
Definition: IntList.hpp:48
Elem * d_current
Definition: IntList.hpp:49
int d_size
Definition: IntList.hpp:51
IntList ( const IntList olist)

Definition at line 9 of file IntList.cpp.

References d_current, d_first, IntList::Elem::d_next, and IntList::Elem::d_val.

9  :
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  }
27 }
Elem * d_first
Definition: IntList.hpp:48
Elem * d_next
Definition: IntList.hpp:37
Elem * d_current
Definition: IntList.hpp:49
int d_size
Definition: IntList.hpp:51
~IntList ( )

Definition at line 30 of file IntList.cpp.

References d_first.

30  {
31  if( d_first ) delete d_first;
32 }
Elem * d_first
Definition: IntList.hpp:48

Member Function Documentation

void append ( int  ed)

Definition at line 57 of file IntList.cpp.

References d_current, d_first, IntList::Elem::d_next, and d_size.

57  {
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 );
71  }
72  d_size++;
73 }
Elem * d_first
Definition: IntList.hpp:48
Elem * d_current
Definition: IntList.hpp:49
int d_size
Definition: IntList.hpp:51
boolean empty ( void  )
inline

Definition at line 88 of file IntList.hpp.

References d_size, FALSE, and TRUE.

88  {
89  return ( d_size <= 0 ? TRUE : FALSE);
90 }
#define FALSE
Definition: vinci.h:133
#define TRUE
Definition: vinci.h:134
int d_size
Definition: IntList.hpp:51
int & get ( )
inline

Definition at line 84 of file IntList.hpp.

References d_current, and IntList::Elem::d_val.

84  {
85  return d_current->d_val;
86 }
Elem * d_current
Definition: IntList.hpp:49
int index ( ) const

Definition at line 110 of file IntList.cpp.

References d_current, d_first, and IntList::Elem::d_next.

110  {
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 }
Elem * d_first
Definition: IntList.hpp:48
Elem * d_next
Definition: IntList.hpp:37
Elem * d_current
Definition: IntList.hpp:49
void index ( int  ind)

Definition at line 121 of file IntList.cpp.

References d_current, d_first, IntList::Elem::d_next, and i.

121  {
122 
123  d_current = d_first;
124  int i;
125  for( i = 0; i < ind; i++ ){
127  }
128 }
Elem * d_first
Definition: IntList.hpp:48
Elem * d_next
Definition: IntList.hpp:37
Elem * d_current
Definition: IntList.hpp:49
blockLoc i
Definition: read.cpp:79
void insert ( int  ed)
inline

Definition at line 55 of file IntList.hpp.

References d_current, d_first, IntList::Elem::d_next, and d_size.

55  { // at d_current
56  assert( d_current || !d_first);
57  d_size++;
58  if( !d_current ){
59  d_first = new IntList::Elem( val );
61  return;
62  }
63  d_current->d_next = new Elem( val, d_current->d_next);
64 }
Elem * d_first
Definition: IntList.hpp:48
Elem * d_next
Definition: IntList.hpp:37
Elem * d_current
Definition: IntList.hpp:49
int d_size
Definition: IntList.hpp:51
void insert_first ( int  ed)
inline

Definition at line 66 of file IntList.hpp.

References d_current, d_first, and d_size.

66  { // at d_current
67  d_size++;
68  d_first = new IntList::Elem( val, d_first);
70 }
Elem * d_first
Definition: IntList.hpp:48
Elem * d_current
Definition: IntList.hpp:49
int d_size
Definition: IntList.hpp:51
boolean move_to ( int  ed)

Definition at line 102 of file IntList.cpp.

References d_current, d_first, IntList::Elem::d_next, IntList::Elem::d_val, FALSE, and TRUE.

102  {
103  d_current = d_first;
104  while( d_current && d_current->d_val != val ){
106  }
107  return( d_current ? TRUE : FALSE );
108 }
#define FALSE
Definition: vinci.h:133
Elem * d_first
Definition: IntList.hpp:48
Elem * d_next
Definition: IntList.hpp:37
Elem * d_current
Definition: IntList.hpp:49
#define TRUE
Definition: vinci.h:134
void next ( )
inline

Definition at line 77 of file IntList.hpp.

References d_current, d_first, and IntList::Elem::d_next.

77  {
79  if( !d_current ){
81  }
82 }
Elem * d_first
Definition: IntList.hpp:48
Elem * d_next
Definition: IntList.hpp:37
Elem * d_current
Definition: IntList.hpp:49
const IntList & operator= ( const IntList olist)

Definition at line 34 of file IntList.cpp.

References d_current, d_first, IntList::Elem::d_next, d_size, and IntList::Elem::d_val.

34  {
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  }
54  return *this;
55 }
Elem * d_first
Definition: IntList.hpp:48
Elem * d_next
Definition: IntList.hpp:37
Elem * d_current
Definition: IntList.hpp:49
int d_size
Definition: IntList.hpp:51
int remove ( )

Definition at line 75 of file IntList.cpp.

References d_current, d_first, IntList::Elem::d_next, d_size, and IntList::Elem::d_val.

75  {
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 ){
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 }
Elem * d_first
Definition: IntList.hpp:48
Elem * d_next
Definition: IntList.hpp:37
Elem * d_current
Definition: IntList.hpp:49
int d_size
Definition: IntList.hpp:51
void reset ( )
inline

Definition at line 73 of file IntList.hpp.

References d_current, and d_first.

73  {
75 }
Elem * d_first
Definition: IntList.hpp:48
Elem * d_current
Definition: IntList.hpp:49
int size ( )
inline

Definition at line 92 of file IntList.hpp.

References d_size.

92  {
93  return d_size;
94 }
int d_size
Definition: IntList.hpp:51

Member Data Documentation

Elem* d_current
private

Definition at line 49 of file IntList.hpp.

Referenced by append(), get(), index(), insert(), insert_first(), IntList(), move_to(), next(), operator=(), remove(), and reset().

Elem* d_first
private
int d_size
private

Definition at line 51 of file IntList.hpp.

Referenced by append(), empty(), insert(), insert_first(), operator=(), remove(), and size().


The documentation for this class was generated from the following files: