1
/* This file is part of MAUS: http://micewww.pp.rl.ac.uk/projects/maus
3
* MAUS is free software: you can redistribute it and/or modify
4
* it under the terms of the GNU General Public License as published by
5
* the Free Software Foundation, either version 3 of the License, or
6
* (at your option) any later version.
8
* MAUS is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with MAUS. If not, see <http:// www.gnu.org/licenses/>.
25
Mesh::Iterator::Iterator() {
28
Mesh::Iterator::Iterator(const Mesh::Iterator& in)
29
: _mesh(in._mesh), _state(in._state) {
32
Mesh::Iterator::Iterator(std::vector<int> state, const Mesh* mesh)
33
: _mesh(mesh), _state(state) {
36
Mesh::Iterator::~Iterator() {
39
int Mesh::Iterator::ToInteger() const {
40
return _mesh->ToInteger(*this);
43
std::vector<int> Mesh::Iterator::State() const {
47
int& Mesh::Iterator::operator[](int i) {
51
const int& Mesh::Iterator::operator[](int i) const {
55
const Mesh* Mesh::Iterator::GetMesh() const {
59
const Mesh::Iterator& Mesh::Iterator::operator= (const Mesh::Iterator& rhs) {
65
void Mesh::Iterator::Position(double* point) const {
66
_mesh->Position(*this, point);
69
std::vector<double> Mesh::Iterator::Position() const {
70
std::vector<double> PointV(_mesh->PositionDimension());
71
_mesh->Position(*this, &PointV[0]);
75
Mesh::Iterator& operator++(Mesh::Iterator& lhs) {
76
return lhs._mesh->AddOne(lhs);
79
Mesh::Iterator& operator--(Mesh::Iterator& lhs) {
80
return lhs._mesh->SubOne(lhs);
83
Mesh::Iterator operator++(Mesh::Iterator& lhs, int) {
84
Mesh::Iterator copy = lhs;
85
lhs._mesh->AddOne(lhs);
89
Mesh::Iterator operator--(Mesh::Iterator& lhs, int) {
90
Mesh::Iterator copy = lhs;
91
lhs._mesh->SubOne(lhs);
95
Mesh::Iterator operator-
96
(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs) {
97
Mesh::Iterator lhsCopy(lhs);
98
Mesh::Iterator lhsNew(lhs._mesh->SubEquals(lhsCopy, rhs));
102
Mesh::Iterator operator- (const Mesh::Iterator& lhs, const int& difference) {
103
Mesh::Iterator lhsCopy(lhs);
104
Mesh::Iterator lhsNew(lhs._mesh->SubEquals(lhsCopy, difference));
108
Mesh::Iterator operator+
109
(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs) {
110
Mesh::Iterator lhsCopy(lhs);
111
Mesh::Iterator lhsNew(lhs._mesh->AddEquals(lhsCopy, rhs));
115
Mesh::Iterator operator+ (const Mesh::Iterator& lhs, const int& difference) {
116
Mesh::Iterator lhsCopy(lhs);
117
Mesh::Iterator lhsNew(lhs._mesh->AddEquals(lhsCopy, difference));
122
Mesh::Iterator& operator+=(Mesh::Iterator& lhs, const Mesh::Iterator& rhs) {
123
return lhs._mesh->AddEquals(lhs, rhs);
126
Mesh::Iterator& operator-=(Mesh::Iterator& lhs, const Mesh::Iterator& rhs) {
127
return lhs._mesh->SubEquals(lhs, rhs);
130
Mesh::Iterator& operator+=(Mesh::Iterator& lhs, const int& rhs) {
131
return lhs._mesh->AddEquals(lhs, rhs);
134
Mesh::Iterator& operator-=(Mesh::Iterator& lhs, const int& rhs) {
135
return lhs._mesh->SubEquals(lhs, rhs);
139
bool operator>=(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs) {
140
if (lhs._mesh->IsGreater(lhs, rhs) || lhs == rhs) return true;
144
bool operator<=(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs) {
145
if (lhs._mesh->IsGreater(lhs, rhs)) return false;
149
bool operator>(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs) {
150
return !(lhs <= rhs);
153
bool operator<(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs) {
154
return !(lhs >= rhs);
157
bool operator==(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs) {
158
if (lhs._state == rhs._state)
163
bool operator!=(const Mesh::Iterator& lhs, const Mesh::Iterator& rhs) {
164
if (lhs._mesh == rhs._mesh && lhs._state == rhs._state)