File indexing completed on 2025-07-09 07:49:31
0001
0002
0003
0004
0005
0006
0007
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 explicit 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 ) {
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 using map_t = std::unordered_map<HashedString, std::unique_ptr<C>>;
0060
0061 DynamicKeyRange(DynamicKeyIterator<C> begin, DynamicKeyIterator<C> end)
0062 : m_begin{begin}, m_end{end} {}
0063
0064 DynamicKeyRange(typename map_t::const_iterator begin,
0065 typename map_t::const_iterator end)
0066 : m_begin{DynamicKeyIterator<C>{begin}},
0067 m_end{DynamicKeyIterator<C>{end}} {}
0068
0069 DynamicKeyIterator<C> begin() const { return m_begin; }
0070 DynamicKeyIterator<C> end() const { return m_end; }
0071
0072 private:
0073 DynamicKeyIterator<C> m_begin;
0074 DynamicKeyIterator<C> m_end;
0075 };
0076
0077 }