Jpp
16.0.1
the software that should make you happy
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
software
JTools
JArrayIterator.hh
Go to the documentation of this file.
1
#ifndef __JTOOLS__JARRAY_ITERATOR__
2
#define __JTOOLS__JARRAY_ITERATOR__
3
4
#include "
JTools/JArray.hh
"
5
#include "
JTools/JAbstractCollection.hh
"
6
7
8
/**
9
* \author mdejong
10
*/
11
12
namespace
JTOOLS {}
13
namespace
JPP {
using namespace
JTOOLS; }
14
15
namespace
JTOOLS {
16
17
/**
18
* ND array iterator.
19
*/
20
template
<
int
N,
class
T>
21
struct
JArrayIterator
:
22
public
JArrayIterator
<N - 1, T>
23
{
24
/**
25
* Constructor.
26
*
27
* \param collection abscissa values
28
*/
29
JArrayIterator
(
const
JAbstractCollection<T>
& collection) :
30
JArrayIterator
<
N
- 1,
T
>(collection)
31
{
32
i
= 0;
33
}
34
35
36
/**
37
* Check validity of iterator.
38
*
39
* \return true if valid; else false
40
*/
41
operator
bool()
const
42
{
43
return
i
!= this->collection.getSize() &&
JArrayIterator
<
N
-1,
T
>::operator bool();
44
}
45
46
47
/**
48
* Get current value.
49
*
50
* \return value
51
*/
52
JArray<N, double>
operator *
()
const
53
{
54
return
JArray<N, double>
(
JArrayIterator<N-1, T>::operator *
(), this->collection.getX(
i
));
55
}
56
57
58
/**
59
* Prefix increment.
60
*
61
* \return this array sampler
62
*/
63
JArrayIterator
&
operator ++
()
64
{
65
if
(++
i
== this->collection.getSize()) {
66
67
i
= 0;
// rewind
68
69
JArrayIterator<N-1, T>::operator ++
();
// increment
70
}
71
72
return
*
this
;
73
}
74
75
76
/**
77
* Postfix increment.
78
*
79
* \return previous array sampler
80
*/
81
JArrayIterator
operator ++
(
int
)
82
{
83
const
JArrayIterator
previous(*
this
);
84
85
++(*this);
86
87
return
previous;
88
}
89
90
private
:
91
int
i
;
92
};
93
94
95
/**
96
* 1D array iterator.
97
*/
98
template
<
class
T>
99
struct
JArrayIterator
<1,
T
>
100
{
101
/**
102
* Constructor.
103
*
104
* \param collection abscissa values
105
*/
106
JArrayIterator
(
const
JAbstractCollection<T>
& collection) :
107
collection(collection)
108
{
109
i
= 0;
110
}
111
112
113
/**
114
* Check validity of iterator.
115
*
116
* \return true if valid; else false
117
*/
118
operator
bool()
const
119
{
120
return
i
!= this->collection.getSize();
121
}
122
123
124
/**
125
* Get current value.
126
*
127
* \return value
128
*/
129
JArray<1, double>
operator *
()
const
130
{
131
return
JArray<1, double>
(this->collection.getX(
i
));
132
}
133
134
135
/**
136
* Prefix increment.
137
*
138
* \return this array sampler
139
*/
140
JArrayIterator
&
operator ++
()
141
{
142
if
(
i
!= this->collection.getSize()) {
143
++
i
;
144
}
145
146
return
*
this
;
147
}
148
149
150
/**
151
* Postfix increment.
152
*
153
* \return previous array sampler
154
*/
155
JArrayIterator
operator ++
(
int
)
156
{
157
const
JArrayIterator
previous(*
this
);
158
159
++(*this);
160
161
return
previous;
162
}
163
164
165
const
JAbstractCollection<T>
&
collection
;
166
167
private
:
168
int
i
;
169
};
170
}
171
172
#endif
JTOOLS::JArrayIterator::i
int i
Definition:
JArrayIterator.hh:91
JTOOLS::JAbstractCollection< T >
N
then JShowerPostfit f $INPUT_FILE o $OUTPUT_FILE N
Definition:
JShowerPostfit.sh:95
JTOOLS::JArrayIterator< 1, T >::JArrayIterator
JArrayIterator(const JAbstractCollection< T > &collection)
Constructor.
Definition:
JArrayIterator.hh:106
JTOOLS::JArrayIterator::operator++
JArrayIterator & operator++()
Prefix increment.
Definition:
JArrayIterator.hh:63
JTOOLS::JArrayIterator
ND array iterator.
Definition:
JArrayIterator.hh:21
JArray.hh
T
do set_variable OUTPUT_DIRECTORY $WORKDIR T
Definition:
JCalibrateHeight.sh:61
JTOOLS::JArray
One dimensional array of template objects with fixed length.
Definition:
JArray.hh:40
JTOOLS::JArrayIterator::operator*
JArray< N, double > operator*() const
Get current value.
Definition:
JArrayIterator.hh:52
JAbstractCollection.hh
JTOOLS::JArrayIterator::JArrayIterator
JArrayIterator(const JAbstractCollection< T > &collection)
Constructor.
Definition:
JArrayIterator.hh:29
JTOOLS::JArrayIterator< 1, T >::collection
const JAbstractCollection< T > & collection
Definition:
JArrayIterator.hh:165
JTOOLS::JArrayIterator< 1, T >::i
int i
Definition:
JArrayIterator.hh:168
Generated by
1.8.5