473,503 Members | 10,012 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

syntax for a vector within a map

I have put an vector array of values within a map. What I don't know
is the syntax for accessing the individual vector values.

map[key][vectorDex].someFunc does run the function but it also creates
a runtime error.

1. What is the proper syntax?

2. Is there anything wrong with choosing this type of structure? So
far, it works.
Jul 19 '05 #1
3 12819
"solartimba" <ka*****@hotmail.com> wrote...
I have put an vector array of values within a map. What I don't know
is the syntax for accessing the individual vector values.

map[key][vectorDex].someFunc does run the function but it also creates
a runtime error.
Post the code, post the data, post the error (read FAQ 5.8).
1. What is the proper syntax?
For what?
2. Is there anything wrong with choosing this type of structure? So
far, it works.


If it works, nothing is wrong (performance can be substandard,
but that's not really "wrong").

Victor
Jul 19 '05 #2
Hi,

"solartimba" <ka*****@hotmail.com> wrote in message
news:1a**************************@posting.google.c om...
I have put an vector array of values within a map. What I don't know
is the syntax for accessing the individual vector values.
You mean something like this

map<string, vector<string> > MapVector;

for( map<string, vector<string> >::const_iterator Walker =
MapVector.begin(); Walker != MapVector.end(); ++Walker )
{
cout << Walker->first << endl;
for( vector<string>::const_iterator WalkerVector = Walker->second.begin();
WalkerVector != Walker->second.end(); ++WalkerVector )
{
cout << *WalkerVector << endl;
}
}
map[key][vectorDex].someFunc does run the function but it also creates
a runtime error.

1. What is the proper syntax?

2. Is there anything wrong with choosing this type of structure? So
far, it works.

Nope, nothing wrong with it.

Regards, Ron AF Greve.

Jul 19 '05 #3
On 24 Oct 2003 10:36:16 -0700, solartimba <ka*****@hotmail.com> wrote:
I have put an vector array of values within a map. What I don't know
is the syntax for accessing the individual vector values.

map[key][vectorDex].someFunc does run the function but it also creates
a runtime error.
map[key] used first time will return a reference to the empty vector so
operator [] will have undefined behaviour.


1. What is the proper syntax?
map[key] returns vector& , vector can be empty.

2. Is there anything wrong with choosing this type of structure? So
far, it works.

Nothing wrong at all

--
grzegorz
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

699
33322
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
4
6184
by: Alex Vinokur | last post by:
Is it possible to use vector<ostringstream> ? Here is what I have got. =========================================== Windows 2000 CYGWIN_NT-5.0 1.3.22(0.78/3/2) GNU gcc version 3.2 20020927...
5
7522
by: cppaddict | last post by:
Is it possible to avoid using push_back repeatedly when initializing a vector? That is, is there a vector syntax that would be analogous to the following array initialization syntax: MyClass...
16
2149
by: Honestmath | last post by:
Hi, I added the following line to my code within a class declaration: std::vector<Date> m_duedates(100); I also tried: std::vector<Date> m_duedates(100, Date());
2
1881
by: bor_kev | last post by:
Hi, First of all, i want to use the new managed class syntax and STL.NET under Microsoft Visual (C++) Studio 2005 Beta. I read in a Microsoft...
18
2926
by: robert | last post by:
Using global variables in Python often raises chaos. Other languages use a clear prefix for globals. * you forget to declare a global * or you declare a global too much or in conflict * you...
9
4591
by: Christian Chrismann | last post by:
Hi, I've a runtime problem with STL vectors. Here is the simplified version of the code: template <class Tclass A { ... private: vector<T*myvector; typename vector<T*>::itarator mIt;
5
12052
by: Alan | last post by:
I was wondering whether it is good programming practice or asking for trouble to modify a vector while iterating through it. That is, I want to do something like the following pseudocode in C++: ...
4
1910
by: Travis | last post by:
I'm creating a real simple tree. No sorting and every node can have infinite children. // TreeNode.h #ifndef TREENODE_H #define TREENODE_H #include <iostream> #include <iomanip>
0
7070
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7267
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4993
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
729
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
372
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.