Open
Graph Drawing
Framework
v.2012.07
Overview
Class Hierarchy
Class Index
Class List
Members
Namespaces
Source Files
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
>
53
#include <
ogdf/basic/CombinatorialEmbedding.h
>
54
55
56
namespace
ogdf {
57
58
60
65
class
FaceArrayBase
{
70
ListIterator<FaceArrayBase*>
m_it
;
71
72
public
:
73
const
ConstCombinatorialEmbedding
*
m_pEmbedding
;
74
76
FaceArrayBase
() :
m_pEmbedding
(0) { }
78
FaceArrayBase
(
const
ConstCombinatorialEmbedding
*pE) :
m_pEmbedding
(pE) {
79
if
(pE)
m_it
= pE->
registerArray
(
this
);
80
}
81
82
// destructor, unregisters the array
83
virtual
~FaceArrayBase
() {
84
if
(
m_pEmbedding
)
m_pEmbedding
->
unregisterArray
(
m_it
);
85
}
86
87
// event interface used by CombinatorialEmbedding
89
virtual
void
enlargeTable
(
int
newTableSize) = 0;
91
virtual
void
reinit
(
int
initTableSize) = 0;
92
94
void
reregister
(
const
ConstCombinatorialEmbedding
*pE) {
95
if
(
m_pEmbedding
)
m_pEmbedding
->
unregisterArray
(
m_it
);
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
() { }
116
FaceArray
(
const
ConstCombinatorialEmbedding
&E) :
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
130
FaceArray
(
const
FaceArray<T>
&A) :
Array
<T>(A),
FaceArrayBase
(A.
m_pEmbedding
),
m_x
(A.
m_x
) { }
131
133
bool
valid
()
const
{
return
(
Array<T>::low
() <=
Array<T>::high
()); }
134
136
const
ConstCombinatorialEmbedding
*
embeddingOf
()
const
{
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
171
FaceArray<T>
&
operator=
(
const
FaceArray<T>
&a) {
172
Array<T>::operator =
(a);
173
m_x
= a.
m_x
;
174
reregister
(a.
m_pEmbedding
);
175
return
*
this
;
176
}
177
179
void
init
() {
180
Array<T>::init
();
reregister
(0);
181
}
182
184
void
init
(
const
ConstCombinatorialEmbedding
&E) {
185
Array<T>::init
(E.
faceArrayTableSize
());
reregister
(&E);
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
213
OGDF_NEW_DELETE
214
215
};
// class FaceArray<T>
216
217
218
}
// end namespace ogdf
219
220
221
#endif
ogdf
basic
FaceArray.h
© 1999-2012 by
TU Dortmund
,
University of Jena
,
University of Cologne
,
University of Sydney
,
oreas GmbH