473,407 Members | 2,546 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,407 software developers and data experts.

how to initialize associate data in map?

Hi everyone,
I used STL map in my code and I am wondering is the associate data automatically initialized or not. The reason I am asking is that I have two arrays of data, and the first array is index, and second array is my data corresponding to the index. But there are duplicate indexs and I want to add up the data of duplicate index.

For example;
map<int index, double data> mid;
mid[index] += data;

So I want to know at beginning, is the data are initialized to 0. or I have to do it myself? Thanks in advance.

Jingbin
Nov 17 '07 #1
2 1460
gpraghuram
1,275 Expert 1GB
Hi everyone,
I used STL map in my code and I am wondering is the associate data automatically initialized or not. The reason I am asking is that I have two arrays of data, and the first array is index, and second array is my data corresponding to the index. But there are duplicate indexs and I want to add up the data of duplicate index.

For example;
map<int index, double data> mid;
mid[index] += data;

So I want to know at beginning, is the data are initialized to 0. or I have to do it myself? Thanks in advance.

Jingbin
mpas dosent allow duplicate indexes, only multi-map allow duplicate index.

Raghu
Nov 19 '07 #2
The map in your case will be initialized to 0.00 . However it is not the case with types such as strings or user classes. which tend to by null(0). So you should be careful.
Nov 20 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: knutsample | last post by:
Hello! I'm trying to associate a file extension to my wxPython script so that all I have to do is double click on the file and my python script will load up with the path of that file. For...
2
by: John Baker | last post by:
Hi: I have used this group a number of times simply because while the manuals for Access may show the technology, but most are really weak on how to apply it in special situations and the...
0
by: Dailan | last post by:
Hi, I create a tree view. Each node has link button associate with it, which includes add, edit, delete buttons. The way I did is for users who have very low capablity of using computer. Now I...
8
by: bryan | last post by:
I'm using the UIP App block and I have overridden the Initialize method, but my override never gets called. Here's the code: public override void Initialize(TaskArgumentsHolder args,...
1
by: Niclas | last post by:
Hi, in ASP .Net, I can associate a value with and item in a dropdown list, for example when binding to a list of employees, I can store the employeeid as a value associated with each name in in...
18
by: toton | last post by:
Hi, In C++ when I initialize an array it, also initializes the class that it contains, which calls the default constructor. However, I want to initialize the array only (i.e reserve the space) and...
1
by: Ryan Liu | last post by:
Hi, As I remember theare are In and Out stream associate with a socket. TcpClient seems there in only one NetworkStream to do both read and write. Then will it be a conflicit if both side try...
4
by: BD | last post by:
Hi all. Running SQL2K SP4 on W2K3 Standard, SP4. I have just refreshed a database on one server with a backup from another. The database had existed previously on the target server, and I am...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.