CMS 3D CMS Logo

printUniqueNames.cc
Go to the documentation of this file.
1 #include "printUniqueNames.h"
2 
3 #include <iostream>
4 #include <iterator>
5 #include <iomanip>
6 
7 using namespace std;
8 
9 void magneticfield::printUniqueNames(handles::const_iterator begin, handles::const_iterator end, bool uniq) {
10  std::vector<std::string> names;
11  for (handles::const_iterator i = begin; i != end; ++i) {
12  if (uniq)
13  names.push_back((*i)->name);
14  else
15  names.push_back((*i)->name + ":" + std::to_string((*i)->copyno));
16  }
17 
18  sort(names.begin(), names.end());
19  if (uniq) {
20  std::vector<std::string>::iterator i = unique(names.begin(), names.end());
21  int nvols = int(i - names.begin());
22  cout << nvols << " ";
23  copy(names.begin(), i, ostream_iterator<std::string>(cout, " "));
24  } else {
25  cout << names.size() << " ";
26  copy(names.begin(), names.end(), ostream_iterator<std::string>(cout, " "));
27  }
28  cout << endl;
29 }
void printUniqueNames(handles::const_iterator begin, handles::const_iterator end, bool uniq=true)
Just for debugging...
std::string to_string(const V &value)
Definition: OMSAccess.h:77
const std::string names[nVars_]
def unique(seq, keepstr=True)
Definition: tier0.py:24