I have a line to pharse like this:
1.2 2 3 4 5
2.4 2.4 2.6 3.5 5.6
3.7 3.4 4.7 3.4 56
I need to sort them in a map of string and vector<double>
The problem I'm having is I'm trying to get each colum and store it in
a vector. But what I'm soring is column.
vector<double> d_vec
map <string, vector<double> > data;
double x;
while (cin >> x)
{
d_vec.push_back(x); // This will push_back each row not column, how to get column.
}
// I have the string keys here. so I don't have to worry about the keys.
for (iter through the string I have as keys)
{
data[keys]= d_vec;
}
Now if I do this:
for (map_iter = data.begin(); map_iter != data.end(); map_iter++)
{
cout << map_iter->first <<endl;
for (vec_iter = data->second.begin(), vec_iter != data->second.end(); vec_iter++)
{
cout << *vec_iter << endl;
}
}
Here there out put shoud be:
Value1
1.2
2.4
3.7
Value2
2
2.4
3.4
value3
4
3.5
3.4
value4
5
5.6
56