23 #ifndef COM_DAFER45_TBTK_SOURCE_AMPLITUDE_SET
24 #define COM_DAFER45_TBTK_SOURCE_AMPLITUDE_SET
26 #include "TBTK/SerializableVector.h"
70 std::vector<SourceAmplitude>&
get(
82 const std::vector<SourceAmplitude>&
get(
91 template<
bool isConstIterator>
96 typedef typename std::conditional<
100 >::type SourceAmplitudeReferenceType;
106 SourceAmplitudeReferenceType
operator*();
109 bool operator==(
const _Iterator &rhs);
116 typedef typename std::conditional<
119 SerializableVector<SourceAmplitude>
122 SerializableVector<SourceAmplitude>
124 >::type IteratorType;
127 unsigned int currentSourceAmplitude;
130 IteratorType iterator;
133 IteratorType iteratorEnd;
142 typedef typename std::conditional<
145 SerializableVector<SourceAmplitude>
148 SerializableVector<SourceAmplitude>
150 >::type SourceAmplitudeTreeType;
155 SourceAmplitudeTreeType &sourceAmplitudeTree,
166 SerializableVector<SourceAmplitude>
167 > &sourceAmplitudeTree,
169 ) : _Iterator(sourceAmplitudeTree,
end){};
182 SerializableVector<SourceAmplitude>
183 > &sourceAmplitudeTree,
185 ) : _Iterator(sourceAmplitudeTree,
end){};
242 std::vector<SourceAmplitude> &sourceAmplitudes
243 = sourceAmplitudeTree.
get(sourceAmplitude.
getIndex());
244 sourceAmplitudes.push_back(sourceAmplitude);
247 sourceAmplitudeTree.
add(
248 std::vector<SourceAmplitude>(),
251 std::vector<SourceAmplitude> &sourceAmplitudes
252 = sourceAmplitudeTree.
get(sourceAmplitude.
getIndex());
253 sourceAmplitudes.push_back(sourceAmplitude);
260 return sourceAmplitudeTree.
get(index);
266 return sourceAmplitudeTree.
get(index);
270 return sizeof(
this) -
sizeof(sourceAmplitudeTree)
274 template<
bool isConstIterator>
275 SourceAmplitudeSet::_Iterator<isConstIterator>::_Iterator(
276 SourceAmplitudeTreeType &sourceAmplitudeTree,
279 currentSourceAmplitude(0),
281 end ? sourceAmplitudeTree.end() : sourceAmplitudeTree.begin()
283 iteratorEnd(sourceAmplitudeTree.end())
287 template<
bool isConstIterator>
288 void SourceAmplitudeSet::_Iterator<isConstIterator>::operator++(){
289 if(iterator != iteratorEnd){
290 const std::vector<SourceAmplitude> &sourceAmplitudes = *iterator;
291 if(currentSourceAmplitude+1 == sourceAmplitudes.size()){
292 currentSourceAmplitude = 0;
296 currentSourceAmplitude++;
301 template<
bool isConstIterator>
302 typename SourceAmplitudeSet::_Iterator<isConstIterator>::SourceAmplitudeReferenceType
303 SourceAmplitudeSet::_Iterator<isConstIterator>::operator*(){
304 return (*iterator)[currentSourceAmplitude];
307 template<
bool isConstIterator>
308 bool SourceAmplitudeSet::_Iterator<isConstIterator>::operator==(
309 const _Iterator<isConstIterator> &rhs
312 iterator == rhs.iterator
313 && currentSourceAmplitude == rhs.currentSourceAmplitude
322 template<
bool isConstIterator>
323 bool SourceAmplitudeSet::_Iterator<isConstIterator>::operator!=(
324 const _Iterator<isConstIterator> &rhs
327 iterator != rhs.iterator
328 || currentSourceAmplitude != rhs.currentSourceAmplitude