ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IndexContainers.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file IndexContainers.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019-2020 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #pragma once
10 
11 #include <boost/container/flat_map.hpp>
12 #include <cstddef>
13 #include <utility>
14 
15 namespace FW {
16 
22 template <typename Value, typename Key = std::size_t>
23 using IndexMultimap = boost::container::flat_multimap<Key, Value>;
24 
30 template <typename Value, typename Key>
32  const IndexMultimap<Value, Key>& multimap) {
33  // switch key-value without enforcing the new ordering (linear copy)
35  unordered.reserve(multimap.size());
36  for (const auto& keyValue : multimap) {
37  // value is now the key and the key is now the value
38  unordered.emplace_back(keyValue.second, keyValue.first);
39  }
40  // adopting the unordered sequence will reestablish the correct order
42  inverse.adopt_sequence(std::move(unordered));
43  return inverse;
44 }
45 
46 } // namespace FW