470,862 Members | 1,720 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,862 developers. It's quick & easy.

A map of varying vectors

Hi

I would like to transform the result of a csv-string (eg.:
"name,age\nstring,int\nMac,23\nMax,24\nMike,78 ") into a map of vectors
map<string, vector<???> >.

The key of the map will be the fieldname (name or age) and the values
are stored as vectors in the indicated type (string, int). Like this i
can call: result["name"][0] (= a string "Mac") or result["age"][0] (=
an int of val 23)

The problem I have: I would like to store the age as int the name as
string. How can I define a map with varying vectors?

Minor problem: Does the STL have a tokeninzing/splitting utiltiy for
strings?

Thanks in advance,
Marco

Mar 21 '06 #1
1 1570
TB
Dekker skrev:
Hi

I would like to transform the result of a csv-string (eg.:
"name,age\nstring,int\nMac,23\nMax,24\nMike,78 ") into a map of vectors
map<string, vector<???> >.

The key of the map will be the fieldname (name or age) and the values
are stored as vectors in the indicated type (string, int). Like this i
can call: result["name"][0] (= a string "Mac") or result["age"][0] (=
an int of val 23)

A simple solution, make two maps:

std::map<std::string, std::vector<std::string> > result_name;
std::map<std::string, std::vector<int> > result_age;
The problem I have: I would like to store the age as int the name as
string. How can I define a map with varying vectors?

Minor problem: Does the STL have a tokeninzing/splitting utiltiy for
strings?


You mean like all those member functions of std::string?

--
TB @ SWEDEN
Mar 21 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Michael Aramini | last post: by
5 posts views Thread by Computer Whizz | last post: by
3 posts views Thread by Amit | last post: by
4 posts views Thread by Dr. J.K. Becker | last post: by
5 posts views Thread by madhu | last post: by
1 post views Thread by Rob | last post: by
2 posts views Thread by joeme | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.