In a map if the values is itself a list then how can we display it.
key: 1 value: 1,2,3 (list)
key: 2 value: 4,5,6 (list)
void somefunction()
{
cout << "Key: " << pos->first << endl;
cout << "Value:" << pos->second << endl;
}
But if pos->second contains a List, how to display it?
I have a function where I am storing all the directories and its corresponding files.
I am facing problem in displaying the of VALUE the map. I have debugged and observed that the corresponding values are getting stored properly but I am not able to display it. Since value part of map is itself a list of pathiterator. Whenever I am getting same filename at different directory I am storing the reference or pathiterator in the map corresponding to the same key(file name).
class FileMgr
{
public:
using path_1 = std::string;
using paths_1 = std::set<path_1>;
using pathiter = paths_1::iterator;
using listofiter = std::list<pathiter>;
using file = std::string;
using store = std::map<file, listofiter>;
using store_iter = store::iterator;
paths_1 pp;
pathiter oo;
listofiter l1;
store s6;
store_iter d;
void addPattern(const std::string& patt)
{
if (patterns_.size() == 1 && patterns_[0] == "*.*")
patterns_.pop_back();
patterns_.push_back(patt);
}
void search()
{
for (recursive_directory_iterator i("."), end; i != end; ++i)
{
pp.insert(i->path().parent_path());
oo = pp.find(i->path().parent_path());
if (!is_directory(i->path()))
{
s6[i->path().filename()].push_back(oo);
}
}
for ( d = s6.begin(); d != s6.end(); d++)
{
cout << "Key: " << d->first << " Value: ";
std::cout << "Value:";
for (auto& x : d->second)
std::cout << ' ' << x;
//^^Red Squiggly here ERROR
std::cout << '\n';
}
}
private:
std::string path_;
DataStore& store_;
patterns patterns_;
};