Open
Graph Drawing
Framework

 v.2012.07
 

FaceArray.h
Go to the documentation of this file.
1 /*
2  * $Revision: 2615 $
3  *
4  * last checkin:
5  * $Author: gutwenger $
6  * $Date: 2012-07-16 14:23:36 +0200 (Mo, 16. Jul 2012) $
7  ***************************************************************/
8 
44 #ifdef _MSC_VER
45 #pragma once
46 #endif
47 
48 #ifndef OGDF_FACE_ARRAY_H
49 #define OGDF_FACE_ARRAY_H
50 
51 
52 #include <ogdf/basic/Array.h>
54 
55 
56 namespace ogdf {
57 
58 
60 
71 
72 public:
74 
79  if(pE) m_it = pE->registerArray(this);
80  }
81 
82  // destructor, unregisters the array
83  virtual ~FaceArrayBase() {
85  }
86 
87  // event interface used by CombinatorialEmbedding
89  virtual void enlargeTable(int newTableSize) = 0;
91  virtual void reinit(int initTableSize) = 0;
92 
96  if ((m_pEmbedding = pE) != 0) m_it = pE->registerArray(this);
97  }
98 }; // class FaceArrayBase
99 
100 
102 
109 template<class T> class FaceArray : private Array<T>, protected FaceArrayBase {
110  T m_x;
111 
112 public:
114  FaceArray() : Array<T>(), FaceArrayBase() { }
117  Array<T>(E.faceArrayTableSize()), FaceArrayBase(&E) { }
119 
123  FaceArray(const ConstCombinatorialEmbedding &E, const T &x) :
124  Array<T>(0,E.faceArrayTableSize()-1,x), FaceArrayBase(&E), m_x(x) { }
126 
131 
133  bool valid() const { return (Array<T>::low() <= Array<T>::high()); }
134 
137  return m_pEmbedding;
138  }
139 
141  const T &operator[](face f) const {
142  OGDF_ASSERT(f != 0 && f->embeddingOf() == m_pEmbedding)
143  return Array<T>::operator [](f->index());
144  }
145 
147  T &operator[](face f) {
148  OGDF_ASSERT(f != 0 && f->embeddingOf() == m_pEmbedding)
149  return Array<T>::operator [](f->index());
150  }
151 
153 
157  const T &operator[](int index) const {
158  return Array<T>::operator [](index);
159  }
160 
162 
166  T &operator[](int index) {
167  return Array<T>::operator [](index);
168  }
169 
173  m_x = a.m_x;
175  return *this;
176  }
177 
179  void init() {
181  }
182 
186  }
187 
189 
193  void init(const ConstCombinatorialEmbedding &E, const T &x) {
194  Array<T>::init(0,E.faceArrayTableSize()-1, m_x = x); reregister(&E);
195  }
196 
198  void fill(const T &x) {
199  int high = m_pEmbedding->maxFaceIndex();
200  if(high >= 0)
201  Array<T>::fill(0,high,x);
202  }
203 
204 private:
205  virtual void enlargeTable(int newTableSize) {
206  Array<T>::grow(newTableSize-Array<T>::size(),m_x);
207  }
208 
209  virtual void reinit(int initTableSize) {
210  Array<T>::init(0,initTableSize-1,m_x);
211  }
212 
214 
215 }; // class FaceArray<T>
216 
217 
218 } // end namespace ogdf
219 
220 
221 #endif