Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:10:46

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/EventData/detail/DynamicColumn.hpp"
0012 #include "Acts/Utilities/HashedString.hpp"
0013 
0014 #include <unordered_map>
0015 
0016 namespace Acts::detail {
0017 
0018 template <typename C>
0019 class DynamicKeyIterator {
0020   using map_t = std::unordered_map<HashedString, std::unique_ptr<C>>;
0021 
0022  public:
0023   using iterator_category = std::forward_iterator_tag;
0024   using value_type = HashedString;
0025   using difference_type = std::ptrdiff_t;
0026   using pointer = void;
0027   using reference = void;
0028 
0029   DynamicKeyIterator(typename map_t::const_iterator it) : m_it{it} {}
0030   DynamicKeyIterator() = default;
0031 
0032   DynamicKeyIterator& operator++() {
0033     m_it++;
0034     return *this;
0035   }
0036 
0037   DynamicKeyIterator operator++(int /*value*/) {
0038     auto copy = *this;
0039     ++(copy.m_it);
0040     return copy;
0041   }
0042 
0043   bool operator==(const DynamicKeyIterator& other) const {
0044     return m_it == other.m_it;
0045   }
0046 
0047   value_type operator*() const { return m_it->first; }
0048 
0049  private:
0050   typename map_t::const_iterator m_it;
0051 };
0052 
0053 static_assert(std::forward_iterator<DynamicKeyIterator<int>>,
0054               "DynamicKeyIterator<int> does not fulfill std::forward_iterator");
0055 
0056 template <typename C>
0057 class DynamicKeyRange {
0058  public:
0059   DynamicKeyRange(DynamicKeyIterator<C> begin, DynamicKeyIterator<C> end)
0060       : m_begin{begin}, m_end{end} {}
0061 
0062   DynamicKeyIterator<C> begin() const { return m_begin; }
0063   DynamicKeyIterator<C> end() const { return m_end; }
0064 
0065  private:
0066   DynamicKeyIterator<C> m_begin;
0067   DynamicKeyIterator<C> m_end;
0068 };
0069 
0070 }  // namespace Acts::detail