ATLAS Offline Software
IndexSet.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6 // 09.05.2005, AUTHOR: OLIVER KORTNER
7 // Modified: 16.07.2006 by O. Kortner, vector size check in initialization
8 // added,
9 // != operator corrected.
10 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
11 
12 #ifndef IndexSetHXX
13 #define IndexSetHXX
14 
15 //::::::::::::::::::::
16 //:: CLASS IndexSet ::
17 //::::::::::::::::::::
18 
27 
29 // HEADER FILES //
31 
32 // standard C++ libraries //
33 #include <iostream>
34 
35 // STEL //
36 #include <vector>
37 
38 namespace MuonCalib {
39 
40  class IndexSet {
41  private:
42  // internal index memory //
43  unsigned int m_nb_indices; // number of indices
44  std::vector<int> m_index; // indices
45 
46  // initialization methods //
47  void init();
48  // default initiailization method; the number of indices is set to 0
49  void init(const unsigned int& r_nb_indices);
50  // initialization method; the number of indices is set to r_nb_indices
51  void init(const unsigned int& r_nb_indices, const std::vector<int>& r_index);
52  // initialization method; the number of indices is set to
53  // r_nb_indices, the vector r_index contains the indices
54 
55  public:
56  // Constructors //
57  IndexSet() { init(); }
59 
60  IndexSet(const unsigned int& r_nb_indices) { init(r_nb_indices); }
62 
63  IndexSet(const unsigned int& r_nb_indices, const std::vector<int>& r_index) { init(r_nb_indices, r_index); }
66 
67  // Methods //
68  unsigned int size() const;
70  void resize(const unsigned int& r_size);
74  int operator[](const unsigned int& r_k);
75  int operator[](const unsigned int& r_k) const;
81  void sort();
83  bool operator==(const IndexSet& r_index_set) const;
84  bool operator!=(const IndexSet& r_index_set) const;
90  };
91 
92 } // namespace MuonCalib
93 
94 #endif
MuonCalib::IndexSet::operator[]
int operator[](const unsigned int &r_k)
:::::::::::::::::::::::
Definition: IndexSet.cxx:121
MuonCalib::IndexSet::size
unsigned int size() const
get the number of indices
Definition: IndexSet.cxx:82
MuonCalib::IndexSet::operator==
bool operator==(const IndexSet &r_index_set) const
Definition: IndexSet.cxx:148
MuonCalib::IndexSet::init
void init()
Definition: IndexSet.cxx:27
MuonCalib::IndexSet::IndexSet
IndexSet()
default constructor: the number of indices is set to 0
Definition: IndexSet.h:57
MuonCalib::IndexSet::m_nb_indices
unsigned int m_nb_indices
Definition: IndexSet.h:43
MuonCalib::IndexSet::IndexSet
IndexSet(const unsigned int &r_nb_indices, const std::vector< int > &r_index)
constructor: the number of indices is set to r_nb_indices, the vector r_index contains the indices
Definition: IndexSet.h:63
MuonCalib
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.
Definition: CscCalcPed.cxx:22
MuonCalib::IndexSet::sort
void sort()
sort the indices in ascending order
Definition: IndexSet.cxx:137
MuonCalib::IndexSet
Definition: IndexSet.h:40
MuonCalib::IndexSet::resize
void resize(const unsigned int &r_size)
resize the index set to r_size; the index store is preserved as far as possible
Definition: IndexSet.cxx:90
MuonCalib::IndexSet::operator!=
bool operator!=(const IndexSet &r_index_set) const
comparison of two index sets; two index sets are considered equal if they are of the same size and th...
Definition: IndexSet.cxx:164
MuonCalib::IndexSet::m_index
std::vector< int > m_index
Definition: IndexSet.h:44
MuonCalib::IndexSet::IndexSet
IndexSet(const unsigned int &r_nb_indices)
constructor: the number of indices is set to r_nb_indices
Definition: IndexSet.h:60