Peano
Loading...
Searching...
No Matches
VertexEnumerator.h
Go to the documentation of this file.
1// This file is part of the Peano project. For conditions of distribution and
2// use, please see the copyright notice at www.peano-framework.org
3#pragma once
4
5
7#include "tarch/Assertions.h"
8
9
10namespace peano4 {
11 namespace datamanagement {
12 template <class Vertex>
13 struct VertexEnumerator;
14 }
15}
16
17
56template <class Vertex>
58 private:
59 Vertex* _vertices[ TwoPowerD ];
60 public:
62 #if PeanoDebug>0
63 for (int i=0; i<TwoPowerD; i++) {
64 _vertices[i] = nullptr;
65 }
66 #endif
67 }
68
73 VertexEnumerator(Vertex* firstVertex) {
74 assertion( firstVertex!=nullptr );
75 for (int i=0; i<TwoPowerD; i++) {
76 _vertices[i] = firstVertex+i;
77 }
78 }
79
80
85 void setPointer(int i, Vertex* value) {
86 assertion(i>=0);
88 assertion(value!=nullptr);
89 _vertices[i] = value;
90 }
91
101 Vertex& operator()(int i) const {
102 assertion1(i>=0,i);
104 assertion1( _vertices[i]!=nullptr,i );
105 return *(_vertices[i]);
106 }
107};
108
109
#define assertion1(expr, param)
#define assertion(expr)
#define TwoPowerD
Definition Globals.h:19
Vertex enumerator within array.
VertexEnumerator(Vertex *firstVertex)
Constructs vertex enumerator with default layout for consecutively stored vertices.
void setPointer(int i, Vertex *value)
Usually is only used by the observers, i.e.
Vertex & operator()(int i) const
Access the ith vertex.