ATLAS Offline Software
ExpandedIdentifier.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //-----------------------------------------------
6 inline ExpandedIdentifier::ExpandedIdentifier(const ExpandedIdentifier& other,
7  size_type start){
8  if (start < other.fields()) {
9  element_vector::const_iterator it = other.m_fields.begin();
10  it += start;
11  m_fields.insert(m_fields.end(), it, other.m_fields.end());
12  }
13 }
14 
15 // Modifications
16 inline void
17 ExpandedIdentifier::add(element_type value){
18  // Max size of id levels should be < 12
19  m_fields.push_back(value);
20 }
21 
22 inline ExpandedIdentifier&
23 ExpandedIdentifier::operator<<(element_type value){
24  // Max size of id levels should be < 12
25  m_fields.push_back(value);
26  return (*this);
27 }
28 
29 inline ExpandedIdentifier::element_type& ExpandedIdentifier::operator[](
30  size_type index){
31  // Raises an exception if index is out-of-bounds.
32  return m_fields.at(index);
33 }
34 
35 inline void
36 ExpandedIdentifier::clear(){
37  m_fields.clear();
38 }
39 
40 inline ExpandedIdentifier::element_type ExpandedIdentifier::operator[](
41  size_type index) const{
42  // Raises an exception if index is out-of-bounds.
43  return m_fields.at(index);
44 }
45 
46 inline ExpandedIdentifier::size_type
47 ExpandedIdentifier::fields() const{
48  return (m_fields.size());
49 }
50 
51 // Comparison operators
52 inline bool
53 ExpandedIdentifier::operator==(const ExpandedIdentifier& other) const{
54  if (fields() != other.fields()) return false;
55  return (m_fields == other.m_fields);
56 }
57 
58 inline auto ExpandedIdentifier::operator <=>( const ExpandedIdentifier& other) const{
59  return std::lexicographical_compare_three_way(m_fields.begin(), m_fields.end(),
60  other.m_fields.begin(), other.m_fields.end());
61 }
62 
63 
64 inline bool
65 ExpandedIdentifier::match(const ExpandedIdentifier& other) const{
66  const auto &[vsmall, vbig] = std::minmax(m_fields, other.m_fields,
67  [](const auto & a1, const auto& a2){return a1.size()<a2.size();});
68  return std::equal(vsmall.begin(), vsmall.end(), vbig.begin());
69 }
70