-
Notifications
You must be signed in to change notification settings - Fork 496
Expand file tree
/
Copy pathArray2D.cxx
More file actions
51 lines (46 loc) · 1.66 KB
/
Array2D.cxx
File metadata and controls
51 lines (46 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#include <Framework/Array2D.h>
#include <Framework/RuntimeError.h>
#include <Framework/CompilerBuiltins.h>
namespace o2::framework
{
labelmap_t LabelMap::populate(uint32_t size, std::vector<std::string> labels)
{
labelmap_t map;
if (labels.empty() == false) {
if (labels.size() != size) {
throw runtime_error("labels array size != array dimension");
}
for (auto i = 0u; i < size; ++i) {
map.emplace(labels[i], (uint32_t)i);
}
}
return map;
}
void LabelMap::replaceLabelsRows(uint32_t size, std::vector<std::string> const& labels)
{
if (O2_BUILTIN_UNLIKELY(size != labels.size())) {
throw runtime_error_f("Row labels array has different size (%d) than number of rows (%d)", labels.size(), size);
};
labels_rows = labels;
rowmap.clear();
rowmap = populate(labels.size(), labels);
}
void LabelMap::replaceLabelsCols(uint32_t size, std::vector<std::string> const& labels)
{
if (O2_BUILTIN_UNLIKELY(size != labels.size())) {
throw runtime_error_f("Column labels array has different size (%d) than number of columns (%d)", labels.size(), size);
};
labels_cols = labels;
colmap.clear();
colmap = populate(labels.size(), labels);
}
} // namespace o2::framework