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

This iterator is able to generate all possible identifiers, from a
fully bounded Range. More...

#include <RangeIterator.h>

Collaboration diagram for RangeIterator:

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

 RangeIterator ()=default
 
 RangeIterator (Range &range)
 
RangeIteratoroperator++ ()
 
RangeIterator begin () const
 
RangeIterator end () const
 
pointer operator-> ()
 
ExpandedIdentifieroperator* ()
 
bool operator== (const RangeIterator &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

This iterator is able to generate all possible identifiers, from a
fully bounded Range.

The precondition is that the Range used to parameterize the iterator
must have all its fields completely bounded.

Definition at line 19 of file RangeIterator.h.

Member Typedef Documentation

◆ difference_type

using RangeIterator::difference_type = std::ptrdiff_t

Definition at line 22 of file RangeIterator.h.

◆ iterator_category

using RangeIterator::iterator_category = std::forward_iterator_tag

Definition at line 21 of file RangeIterator.h.

◆ pointer

Definition at line 24 of file RangeIterator.h.

◆ reference

Definition at line 25 of file RangeIterator.h.

◆ value_type

Definition at line 23 of file RangeIterator.h.

Constructor & Destructor Documentation

◆ RangeIterator() [1/2]

RangeIterator::RangeIterator ( )
default

◆ RangeIterator() [2/2]

RangeIterator::RangeIterator ( 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 41 of file RangeIterator.cxx.

41  : m_range (&range) {
48  for (Range::size_type i = 0; i < range.fields (); ++i) {
49  Range::element_type minimum;
50  Range::element_type maximum;
51  m_indices.push_back (0);
52  const Range::field& f = range[i];
53  if (f.empty()){
54  m_id << 0;
55  m_min << 0;
56  m_max << 0;
57  } else {
58  minimum = f.get_minimum ();
59  maximum = f.get_maximum ();
60  m_id << minimum;
61  m_min << minimum;
62  m_max << maximum;
63  }
64  }
65 }

Member Function Documentation

◆ begin()

RangeIterator RangeIterator::begin ( ) const

Definition at line 12 of file RangeIterator.cxx.

12  {
13  return (*this);
14 }

◆ end()

RangeIterator RangeIterator::end ( ) const

Definition at line 24 of file RangeIterator.cxx.

24  {
25  Range r;
26  RangeIterator factory(r);
27  return (factory);
28 }

◆ operator*()

ExpandedIdentifier & RangeIterator::operator* ( )

Definition at line 137 of file RangeIterator.cxx.

137  {
138  return (m_id);
139 }

◆ operator++()

RangeIterator & RangeIterator::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 71 of file RangeIterator.cxx.

71  {
72  if (m_id.fields () == 0) return *this;
74  Range::size_type i = fields - 1;
75 
76  //
77  // Starting from the end, we try to increment the m_id fields
78  // If at a given position it's not possible (max reached)
79  // then we move back one pos and try again.
80  //
81  // As soon as increment is possible, then the rest of the m_id
82  // is reset to min values.
83  //
84 
85  for (;;) {
86  const Range::field& f = (*m_range)[i];
87  bool done = false;
89 
90  if (f.isEnumerated()) {
92  index++;
93  if (index < f.get_indices ()) {
94  m_indices[i] = index;
95  value = f.get_value_at (index);
96  done = true;
97  }
98  } else {
99  value = m_id[i];
100  if (value < m_max[i]) {
105  ++value;
106  done = true;
107  }
108  }
109  if (done) {
110  m_id[i] = value;
111  for (++i; i < fields; ++i) {
112  m_indices[i] = 0;
113  m_id[i] = m_min[i];
114  }
115 
116  break;
117  }
118 
124  if (i == 0) {
125  m_id.clear ();
126  break;
127  }
128 
129  --i;
130 
131  }
132  return *this;
133 }

◆ operator->()

pointer RangeIterator::operator-> ( )
inline

Definition at line 34 of file RangeIterator.h.

34 { return &m_id; }

◆ operator==()

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

Definition at line 143 of file RangeIterator.cxx.

143  {
144  if (m_id == other.m_id) return (true);
145  return (false);
146 }

Member Data Documentation

◆ m_id

ExpandedIdentifier RangeIterator::m_id
private

Definition at line 40 of file RangeIterator.h.

◆ m_indices

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

Definition at line 39 of file RangeIterator.h.

◆ m_max

ExpandedIdentifier RangeIterator::m_max
private

Definition at line 42 of file RangeIterator.h.

◆ m_min

ExpandedIdentifier RangeIterator::m_min
private

Definition at line 41 of file RangeIterator.h.

◆ m_range

const Range* RangeIterator::m_range {}
private

Definition at line 43 of file RangeIterator.h.


The documentation for this class was generated from the following files:
RangeIterator::m_indices
std::vector< std::size_t > m_indices
Definition: RangeIterator.h:39
beamspotman.r
def r
Definition: beamspotman.py:676
Range::size_type
ExpandedIdentifier::size_type size_type
Definition: DetectorDescription/Identifier/Identifier/Range.h:33
index
Definition: index.py:1
RangeIterator
This iterator is able to generate all possible identifiers, from a fully bounded Range.
Definition: RangeIterator.h:19
athena.value
value
Definition: athena.py:124
ExpandedIdentifier::fields
size_type fields() const
RangeIterator::m_max
ExpandedIdentifier m_max
Definition: RangeIterator.h:42
lumiFormat.i
int i
Definition: lumiFormat.py:85
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
RangeIterator::m_range
const Range * m_range
Definition: RangeIterator.h:43
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
RangeIterator::m_min
ExpandedIdentifier m_min
Definition: RangeIterator.h:41
ExpandedIdentifier::clear
void clear()
Erase all fields.
CaloCondBlobAlgs_fillNoiseFromASCII.fields
fields
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:106
Range::element_type
ExpandedIdentifier::element_type element_type
Definition: DetectorDescription/Identifier/Identifier/Range.h:32
RangeIterator::m_id
ExpandedIdentifier m_id
Definition: RangeIterator.h:40