Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ElementList.hpp
Go to the documentation of this file.
1 #ifndef ELEMENTLIST_HPP
2 #define ELEMENTLIST_HPP
3 
4 #include "general.hpp"
5 #include "Element.hpp"
6 
7 class ElementList {
8 public:
9 
10  ElementList();
11  ElementList( const ElementList& olist );
12  ~ElementList();
13 
14  const ElementList& operator=( const ElementList& olist);
15 
16  void append(Element* val);
17  void insert(Element* val);
18  void insert_first(Element* val);
19 
20  void reset();
21  void next();
22 
23  Element* get();
24  Element* remove();
25 
26  boolean empty();
27  int size();
28 
29  boolean move_to(Element* val);
30  int index() const;
31  void index( int ind );
32 
33 private:
34 
35  struct Elem {
38 
39  Elem() : d_val(0), d_next(0) {}
40  Elem(Element* val, Elem* next = 0) :
41  d_val(val), d_next(next) {}
42 
43  ~Elem() {
44  if( d_next ) delete d_next;
45  }
46  };
47 
50 
51  int d_size;
52 };
53 
54 
55 inline void ElementList::insert(Element* val) { // at d_current
56  if( !d_current && d_first){
57  cerr << " Gevalt - insert\n";
58  return;
59  }
60  d_size++;
61  if( !d_current ){
62  d_first = new ElementList::Elem( val );
64  return;
65  }
66  d_current->d_next = new Elem( val, d_current->d_next);
67 }
68 
69 inline void ElementList::insert_first(Element* val) { // at d_current
70  d_size++;
71  d_first = new ElementList::Elem( val, d_first);
73 }
74 
75 
76 inline void ElementList::reset() {
78 }
79 
80 inline void ElementList::next() {
82  if( !d_current ){
84  }
85 }
86 
88  return d_current->d_val;
89 }
90 
91 inline boolean ElementList::empty(){
92  return ( d_size <= 0 ? TRUE : FALSE);
93 }
94 
95 inline int ElementList::size(){
96  return d_size;
97 }
98 
99 
100 #endif
101 
102 
103 
104 
#define FALSE
Definition: vinci.h:133
void insert(Element *val)
Definition: ElementList.hpp:55
Element * get()
Definition: ElementList.hpp:87
boolean empty()
Definition: ElementList.hpp:91
const ElementList & operator=(const ElementList &olist)
Definition: ElementList.cpp:35
void reset()
Definition: ElementList.hpp:76
#define TRUE
Definition: vinci.h:134
Elem * d_first
Definition: ElementList.hpp:48
void insert_first(Element *val)
Definition: ElementList.hpp:69
int index() const
Elem * d_current
Definition: ElementList.hpp:49
Elem(Element *val, Elem *next=0)
Definition: ElementList.hpp:40
boolean move_to(Element *val)
void append(Element *val)
Definition: ElementList.cpp:58