File indexing completed on 2024-04-06 12:22:30
0001 #include "printUniqueNames.h"
0002
0003 #include <iostream>
0004 #include <iterator>
0005 #include <iomanip>
0006
0007 using namespace std;
0008
0009 void magneticfield::printUniqueNames(handles::const_iterator begin, handles::const_iterator end, bool uniq) {
0010 std::vector<std::string> names;
0011 for (handles::const_iterator i = begin; i != end; ++i) {
0012 if (uniq)
0013 names.push_back((*i)->name);
0014 else
0015 names.push_back((*i)->name + ":" + std::to_string((*i)->copyno));
0016 }
0017
0018 sort(names.begin(), names.end());
0019 if (uniq) {
0020 std::vector<std::string>::iterator i = unique(names.begin(), names.end());
0021 int nvols = int(i - names.begin());
0022 cout << nvols << " ";
0023 copy(names.begin(), i, ostream_iterator<std::string>(cout, " "));
0024 } else {
0025 cout << names.size() << " ";
0026 copy(names.begin(), names.end(), ostream_iterator<std::string>(cout, " "));
0027 }
0028 cout << endl;
0029 }