|
ATLAS Offline Software
|
Go to the documentation of this file.
5 #ifndef XAODINDETMEASUREMENT_CONTAINERACCESSOR_H
6 #define XAODINDETMEASUREMENT_CONTAINERACCESSOR_H
10 #include <boost/container/small_vector.hpp>
12 #include <unordered_map>
24 template <
typename value_t,
typename identifier_t,
size_t inline_size = 10>
30 using Range = std::pair<Iterator, Iterator>;
42 std::function<identifier_t(
const value_t&)> mapper,
size_t max_ids=2000) {
44 std::optional<identifier_t> prev = std::nullopt;
47 identifier_t
id = mapper(**
it);
48 if (prev && (*prev) !=
id) {
70 boost::container::small_vector<Range, inline_size> rangesForId =
m_ranges.at(
identifier);
85 std::vector<identifier_t>
ids{};
87 for (
const auto& id_range :
m_ranges)
88 ids.push_back(id_range.first);
93 std::unordered_map<identifier_t, boost::container::small_vector<Range, inline_size>>
m_ranges;
97 #endif // XAODINDETMEASUREMENT_CONTAINERACCESSOR_H
std::vector< identifier_t > allIdentifiers() const
Function to return all available identifier (i.e. keys in the map)
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
typename container_t::const_iterator Iterator
ContainerAccessor(const ContainerAccessor &)=delete
Copy constructor, deleted.
const boost::container::small_vector< Range, inline_size > rangesForIdentifierDirect(const identifier_t &identifier) const
Function to return the list of ranges corresponding to a given identifier.
std::unordered_map< identifier_t, boost::container::small_vector< Range, inline_size > > m_ranges
ContainerAccessor & operator=(const ContainerAccessor &)=delete
A Range describes the possible ranges for the field values of an ExpandedIdentifier.
~ContainerAccessor()=default
Default destructor.
An STL vector of pointers that by default owns its pointed-to elements.
ContainerAccessor(const container_t &values, std::function< identifier_t(const value_t &)> mapper, size_t max_ids=2000)
Constructor.
bool isIdentifierPresent(const identifier_t &identifier) const
Function to verify if a given identifier is present in the map, i.e.