38 const std::string& Ids)
const {
39 std::vector<Index> result;
41 const std::string delimiter =
":";
42 for (std::string s : results) {
43 if (s.find(delimiter) != std::string::npos) {
44 std::string copy_s = s;
47 boost::lexical_cast<Index>(s.substr(0, s.find(delimiter)));
48 Index stop = boost::lexical_cast<Index>(
49 s.erase(0, s.find(delimiter) + delimiter.length()));
50 for (
Index i = start; i <= stop; i++) {
53 }
catch (boost::bad_lexical_cast&) {
54 throw std::runtime_error(
"Could not convert " + copy_s +
55 " to range of integers.");
59 result.push_back(boost::lexical_cast<Index>(s));
60 }
catch (boost::bad_lexical_cast&) {
61 throw std::runtime_error(
"Could not convert " + s +
" to integer.");
66 std::set<Index> s(result.begin(), result.end());
67 result.assign(s.begin(), s.end());
72 const std::vector<Index>& indeces)
const {
73 std::set<Index> s(indeces.begin(), indeces.end());
74 std::vector<Index> sorted_unique(s.begin(), s.end());
75 std::string result =
"";
76 if (sorted_unique.empty()) {
80 std::vector<Index> difference(sorted_unique.size() + 1);
81 difference.back() = 0;
82 std::adjacent_difference(sorted_unique.begin(), sorted_unique.end(),
85 bool range_started =
false;
87 for (
Index i = 0; i <
Index(sorted_unique.size()); i++) {
88 if (difference[i + 1] == 1) {
93 startindex = sorted_unique[i];
97 result += std::to_string(startindex) +
":" +
98 (std::to_string(sorted_unique[i])) +
" ";
99 range_started =
false;
101 result += (std::to_string(sorted_unique[i])) +
" ";