473,231 Members | 1,390 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,231 software developers and data experts.

what datatypes of key can be used in c++ maps?

I want to used datastructure in which key value i want to use is
String pointer & associated with each key there is one dimensional
integer array which i want dynamic because size of integer array may be
variable .So can anyone suggest me can I use maps or what datastructure
will be suitable?
Aparna :-)

Feb 9 '06 #1
5 1507
* aparna:
I want to used datastructure in which key value i want to use is
String pointer & associated with each key there is one dimensional
integer array which i want dynamic because size of integer array may be
variable .So can anyone suggest me can I use maps or what datastructure
will be suitable?


std::map< std::string, std::vector<int> >

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Feb 9 '06 #2
map<string, int*> may be suitable. Or you can wrap int* in a smart
pointer. Just note that if you use string* as the key, that means you
are using address of a string as the key instead of the actual content
of the string.

Feb 9 '06 #3

"aparna" <ap********@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
I want to used datastructure in which key value i want to use is
String pointer & associated with each key there is one dimensional
integer array which i want dynamic because size of integer array may be
variable .So can anyone suggest me can I use maps or what datastructure
will be suitable?


Why don't you use a std::map<std::string, std::vector<int> >?

Regards,
Sumit.

Feb 9 '06 #4

ferdinand.stefa...@gmail.com wrote:
map<string, int*> may be suitable. Or you can wrap int* in a smart
pointer. Just note that if you use string* as the key, that means you
are using address of a string as the key instead of the actual content
of the string.


Or better yet, as other people have mentioned, use map<string,
vector<int> >

Feb 9 '06 #5
The way I read it you want to a map<std::string*,std::vector<int> >. (A
reference to a string pointer)
This is also fine but you need to think a bit about what you are doing.

In effect this maps a vector to the memory address where your string
object resides.

Be sure to declare a comparator if you want to sort your map.
(
something like:
class CompareStringPointers
{
bool operator()(const std::string* A,const std::string* B ) const
{return *A<*B;}
};
)

Feb 9 '06 #6

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

Similar topics

4
by: Jeff Sandys | last post by:
I'm trying to write a mapping function for genealogy. I want to read a gedcom database and plot an icon at a geographic location based on a user's query. Can you help me find: 1) A python...
3
by: Sean | last post by:
Have you ever wanted to add the great features inherent in Google Maps? Here is how you do it. ============== == STEP ONE == ============== Create a new MS Access form called frmGoogleMap....
35
by: Sunil | last post by:
Hi all, I am using gcc compiler in linux.I compiled a small program int main() { printf("char : %d\n",sizeof(char)); printf("unsigned char : ...
3
by: madsen | last post by:
Hi, I am a developper who needs to return a collection of different datatypes. Have considered using an array containing arraylists. Is it posible? or is there a better way? Would like to use some...
21
by: Helge Jensen | last post by:
I've got some data that has Set structure, that is membership, insert and delete is fast (O(1), hashing). I can't find a System.Collections interface that matches the operations naturally offered...
21
by: Jim Langston | last post by:
I'm sure this has been asked a few times, but I'm still not sure. I want to create a function to simplify getting a reference to a CMap in a map. This is what I do now in code: ...
16
by: SLIMSHIM | last post by:
Hi, I"m new to c# and .net. I wrote a small program to add rows to an access table. the program goes thru the motions but the data never gets there. here is my code. I am intentionaly not using...
2
by: rn5arn5a | last post by:
I am not sure where I should have posted this question in this newsgroup. Please excuse me if I am wrong. Nowadays, a lot of websites have come with Maps (Google Maps being an example). Can...
3
by: Phil Stanton | last post by:
I have a button on a form which when pressed displays a google map of the address. Code is Private Sub Googlemap_Click() MakeURL ("") End Sub
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.