ATLAS Offline Software
Public Types | Public Member Functions | Private Attributes | List of all members
ConstRangeIterator Class Reference

#include <RangeIterator.h>

Collaboration diagram for ConstRangeIterator:

Public Types

using iterator_category = std::forward_iterator_tag
 
using difference_type = std::ptrdiff_t
 
using value_type = ExpandedIdentifier
 
using pointer = ExpandedIdentifier *
 
using reference = ExpandedIdentifier &
 

Public Member Functions

 ConstRangeIterator ()=default
 
 ConstRangeIterator (const Range &range)
 
ConstRangeIterator begin () const
 
ConstRangeIterator end () const
 
ConstRangeIterator operator++ ()
 
const ExpandedIdentifieroperator* () const
 
bool operator== (const ConstRangeIterator &other) const
 

Private Attributes

std::vector< std::size_t > m_indices
 
ExpandedIdentifier m_id
 
ExpandedIdentifier m_min
 
ExpandedIdentifier m_max
 
const Rangem_range {}
 

Detailed Description

Definition at line 46 of file RangeIterator.h.

Member Typedef Documentation

◆ difference_type

using ConstRangeIterator::difference_type = std::ptrdiff_t

Definition at line 49 of file RangeIterator.h.

◆ iterator_category

using ConstRangeIterator::iterator_category = std::forward_iterator_tag

Definition at line 48 of file RangeIterator.h.

◆ pointer

Definition at line 51 of file RangeIterator.h.

◆ reference

Definition at line 52 of file RangeIterator.h.

◆ value_type

Definition at line 50 of file RangeIterator.h.

Constructor & Destructor Documentation

◆ ConstRangeIterator() [1/2]

ConstRangeIterator::ConstRangeIterator ( )
default

◆ ConstRangeIterator() [2/2]

ConstRangeIterator::ConstRangeIterator ( const Range range)

Fill all running identifiers m_id : the current id m_min : the set of low bounds m_max : the set of high bounds

Definition at line 151 of file RangeIterator.cxx.

151  :
152  m_range (&range) {
159  for (Range::size_type i = 0; i < range.fields (); ++i) {
160  Range::element_type minimum;
161  Range::element_type maximum;
162  m_indices.push_back (0);
163  const Range::field& f = range[i];
164  if (f.empty()){
165  m_id << 0;
166  m_min << 0;
167  m_max << 0;
168  } else {
169  minimum = f.get_minimum ();
170  maximum = f.get_maximum ();
171  m_id << minimum;
172  m_min << minimum;
173  m_max << maximum;
174  }
175  }
176 }

Member Function Documentation

◆ begin()

ConstRangeIterator ConstRangeIterator::begin ( ) const

Definition at line 18 of file RangeIterator.cxx.

18  {
19  return (*this);
20 }

◆ end()

ConstRangeIterator ConstRangeIterator::end ( ) const

Definition at line 32 of file RangeIterator.cxx.

32  {
33  static const Range r;
34  static const ConstRangeIterator factory(r);
35  return (factory);
36 }

◆ operator*()

const ExpandedIdentifier & ConstRangeIterator::operator* ( ) const

Definition at line 244 of file RangeIterator.cxx.

244  {
245  return (m_id);
246 }

◆ operator++()

ConstRangeIterator ConstRangeIterator::operator++ ( )

The local range is not exceeded. increase the value then reset the remaining fields.

The current range field was exhausted check the previous one.

Definition at line 181 of file RangeIterator.cxx.

181  {
182  if (m_id.fields () == 0) return *this;
184  Range::size_type i = fields - 1;
185  //
186  // Starting from the end, we try to increment the m_id fields
187  // If at a given position it's not possible (max reached)
188  // then we move back one pos and try again.
189  //
190  // As soon as increment is possible, then the rest of the m_id
191  // is reset to min values.
192  //
193  for (;;){
194  const Range::field& f = (*m_range)[i];
195  bool done = false;
197 
198  if (f.isEnumerated()) {
200  index++;
201  if (index < f.get_indices ()) {
202  m_indices[i] = index;
203  value = f.get_value_at (index);
204  done = true;
205  }
206  }else {
207  value = m_id[i];
208  if (value < m_max[i]){
213  ++value;
214  done = true;
215  }
216  }
217 
218  if (done) {
219  m_id[i] = value;
220  for (++i; i < fields; ++i) {
221  m_indices[i] = 0;
222  m_id[i] = m_min[i];
223  }
224  break;
225  }
226 
232  if (i == 0) {
233  m_id.clear ();
234  break;
235  }
236  --i;
237 
238  }
239  return *this;
240 }

◆ operator==()

bool ConstRangeIterator::operator== ( const ConstRangeIterator other) const

Definition at line 250 of file RangeIterator.cxx.

250  {
251  if (m_id == other.m_id) return (true);
252  return (false);
253 }

Member Data Documentation

◆ m_id

ExpandedIdentifier ConstRangeIterator::m_id
private

Definition at line 66 of file RangeIterator.h.

◆ m_indices

std::vector<std::size_t> ConstRangeIterator::m_indices
private

Definition at line 65 of file RangeIterator.h.

◆ m_max

ExpandedIdentifier ConstRangeIterator::m_max
private

Definition at line 68 of file RangeIterator.h.

◆ m_min

ExpandedIdentifier ConstRangeIterator::m_min
private

Definition at line 67 of file RangeIterator.h.

◆ m_range

const Range* ConstRangeIterator::m_range {}
private

Definition at line 69 of file RangeIterator.h.


The documentation for this class was generated from the following files:
ConstRangeIterator::m_indices
std::vector< std::size_t > m_indices
Definition: RangeIterator.h:65
beamspotman.r
def r
Definition: beamspotman.py:676
ConstRangeIterator
Definition: RangeIterator.h:46
ConstRangeIterator::m_id
ExpandedIdentifier m_id
Definition: RangeIterator.h:66
Range::size_type
ExpandedIdentifier::size_type size_type
Definition: DetectorDescription/Identifier/Identifier/Range.h:33
index
Definition: index.py:1
athena.value
value
Definition: athena.py:124
ExpandedIdentifier::fields
size_type fields() const
ConstRangeIterator::m_range
const Range * m_range
Definition: RangeIterator.h:69
lumiFormat.i
int i
Definition: lumiFormat.py:85
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
hist_file_dump.f
f
Definition: hist_file_dump.py:135
Range
A Range describes the possible ranges for the field values of an ExpandedIdentifier.
Definition: DetectorDescription/Identifier/Identifier/Range.h:29
DeMoScan.index
string index
Definition: DeMoScan.py:364
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
IdentifierField
This is the individual specification for the range of one ExpandedIdentifier IdentifierField.
Definition: IdentifierField.h:21
ExpandedIdentifier::clear
void clear()
Erase all fields.
CaloCondBlobAlgs_fillNoiseFromASCII.fields
fields
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:106
ConstRangeIterator::m_max
ExpandedIdentifier m_max
Definition: RangeIterator.h:68
ConstRangeIterator::m_min
ExpandedIdentifier m_min
Definition: RangeIterator.h:67
Range::element_type
ExpandedIdentifier::element_type element_type
Definition: DetectorDescription/Identifier/Identifier/Range.h:32