File indexing completed on 2023-03-17 10:51:39
0001 #include "DetectorDescription/Core/interface/DDsvalues.h"
0002
0003 #include <iostream>
0004
0005 void merge(DDsvalues_type &target, DDsvalues_type const &sv, bool sortit ) {
0006 if (target.empty()) {
0007 target = sv;
0008 return;
0009 }
0010 DDsvalues_type::const_iterator sit = sv.begin();
0011 DDsvalues_type::const_iterator sed = sv.end();
0012
0013 if (target.back() < sv.front()) {
0014 target.insert(target.end(), sit, sed);
0015 return;
0016 }
0017 if (sv.back() < target.front()) {
0018 target.insert(target.begin(), sit, sed);
0019 return;
0020 }
0021 {
0022 DDsvalues_type::iterator it = std::lower_bound(target.begin(), target.end(), sv.front());
0023 if (it == std::lower_bound(target.begin(), target.end(), sv.back())) {
0024 target.insert(it, sit, sed);
0025 return;
0026 }
0027 }
0028
0029 target.reserve(target.size() + sv.size());
0030 DDsvalues_type::const_iterator ted = target.end();
0031 for (; sit != sed; ++sit) {
0032 DDsvalues_type::const_iterator it = find(target.begin(), ted, (*sit).first);
0033 if (it != ted)
0034 const_cast<DDsvalues_Content_type &>(*it).second = (*sit).second;
0035 else
0036 target.emplace_back(*sit);
0037 }
0038 if (sortit)
0039 std::sort(target.begin(), target.end());
0040 }
0041
0042 std::ostream &operator<<(std::ostream &os, const DDsvalues_type &s) {
0043 DDsvalues_type::const_iterator it = s.begin();
0044 for (; it != s.end(); ++it) {
0045 os << it->second;
0046
0047
0048
0049
0050
0051
0052
0053 }
0054 return os;
0055 }
0056
0057 std::ostream &operator<<(std::ostream &os, const std::vector<const DDsvalues_type *> &v) {
0058 for (const auto &i : v) {
0059 os << *i;
0060 }
0061
0062 return os;
0063 }
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079 bool DDfetch(const DDsvalues_type *p, DDValue &v) {
0080 bool result = false;
0081 DDsvalues_type::const_iterator it = find(*p, v);
0082 if (it != p->end()) {
0083 result = true;
0084 v = it->second;
0085 }
0086 return result;
0087 }
0088
0089 unsigned int DDfetch(const std::vector<const DDsvalues_type *> &sp, DDValue &toFetch, std::vector<DDValue> &result) {
0090 unsigned int count = 0;
0091 for (const auto &it : sp) {
0092 if (DDfetch(it, toFetch)) {
0093 result.emplace_back(toFetch);
0094 ++count;
0095 }
0096 }
0097 return count;
0098 }