A Map Question

U

utab

Dear all,

I am trying to create a look-up table for a text search and replacement
class which will be used with a commercial software(MCS NASTRAN, I
guess you may have heard that before ).

I want to create a table like

vector<string> ===mapping=== (vector<string>, vector<int>)

more clearly, as an example:

GRID GRID 1
ID 2
CP 3
X1 4
X2 5
X3 6
CD 7
PS 8
SEID 9

Here there will be another entry like this

Field1 string1 int1
. .
. .
string9 int2

So I tried something with a nested map, but the problem is that(I
think) since the elements of a map are pairs and the keys of these
pairs are constant, I could not initialize that with the values I
wanted, take a look at:

map<vector<string>,map<vector<string>,vector<int> > > mapp;
map<vector<string>,map<vector<string>,vector<int> > >::iterator
iter_;
map<vector<string>,vector<int> >::iterator iter__;

iter_->first.push_back("GRID");
(iter_->second).(iter__->first.push_back("GRID"));
(iter_->second).(iter__->second.push_back(1));

Since my stl knowledge is limited, I need help from experienced
programmers.

I got one reply which I can use

http://groups.google.com/group/comp...636a05a081e/2b12a11ff0f4d7dd#2b12a11ff0f4d7dd

The thing I am curious about is that can we give a vector as a key to
map. And if yes how can we initialize that with the vector version?

Regards,
 
K

Kai-Uwe Bux

utab said:
Dear all,

I am trying to create a look-up table for a text search and replacement
class which will be used with a commercial software(MCS NASTRAN, I
guess you may have heard that before ).

I want to create a table like

vector<string> ===mapping=== (vector<string>, vector<int>)

more clearly, as an example:

GRID GRID 1
ID 2
CP 3
X1 4
X2 5
X3 6
CD 7
PS 8
SEID 9

Here there will be another entry like this

Field1 string1 int1
. .
. .
string9 int2

From these examples, I do not understand why you say that you are mapping
vector<string> objects to pair< vector<string>, vector<int> > object. It
appears that you are just dealing with a

map< string, map< string, int > >

and this map would take "GRID" to the map

"GRID" -> 1
"ID" -> 2
...


What am I missing?


[snip]


Best

Kai-Uwe Bux
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top