|
I can see no standard compliance requirements in the original post, but your assumptions seem right.
|
|
|
|
|
multimap<string, string> mymap;
string strKey;
:
:
multimap<string, string>::iterator it;
:
it = mymap.find( strKey );
if(it != mymap.end())
{
do
{
cout << strKey << " = " << it->second << "\n";
it++;
}
while( it != mymap.upper_bound( strKey ));
}
|
|
|
|
|
This is inefficient. Why calculate the upper bound each loop?
Steve
|
|
|
|
|
cppreference.com
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Try something like this:
#include "stdafx.h"
#include <iostream>
#include <string>
#include <map>
void Go()
{
using namespace std;
typedef multimap<int, string> Tmm;
typedef Tmm::value_type TmmVal;
typedef Tmm::const_iterator TmmIt;
Tmm mm;
mm.insert(TmmVal(1, "One"));
mm.insert(TmmVal(1, "Single"));
mm.insert(TmmVal(2, "Two"));
mm.insert(TmmVal(2, "1+1"));
mm.insert(TmmVal(2, "Duo"));
mm.insert(TmmVal(3, "Three"));
pair<TmmIt, TmmIt> ip = mm.equal_range(2);
for (TmmIt it=ip.first; it!=ip.second; ++it)
{
cout << it->first << " : " << it->second << endl;
}
}
int main(int argc, char* argv[])
{
Go();
return 0;
}
Output is:
2 : Two
2 : 1+1
2 : Duo
Steve
|
|
|
|
|
I need to handle more than 1 lakhs entries inside a data structure.
I am thinking to use std::map becuase of ease of searching.
Is map can hold more than 1 lakhs entires? If not what data strucure should I use to perform fast search opeartion?
|
|
|
|
|
john5632 wrote: I am thinking to use std::map becuase of ease of searching.
Is map can hold more than 1 lakhs entires? If not what data strucure should I use to perform fast search opeartion?
yes map can hold such a large data-structure, does your computer has enough memory for same first, second you can check that yourself by writing small program
like:-
map<int,int> intMap;
for(int i=0;i<100000;i++)
{
intMap.insert(map<int,int>::value_type(i,i));
}
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
|
Hi all,
Can anyone suggest me,how can i drag and drop a bitmap on the dialog.
Actually i am loading a bitmap on OnPaint.How can i get the control of it so that i can move it accordingly...
Any example or any good links will be helpful
Thanks
Sharan
|
|
|
|
|
manju 3 wrote: Can anyone suggest me,how can i drag and drop a bitmap on the dialog.
for drag & drop, your control should support it. read more here :- Drag and Drop in a Dialog[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi Alok,
Thanks for your reply.I checked with that given demo.
If i am not wrong that demo is not for Bitmap.It will just droping the file path draged outside the dialog.
Actually i am loading a bitmap on the dialog,Then i need to select that bitmap and move accordingly with Mouse movement.
Thanks
Sharan
|
|
|
|
|
A simple Google search yields this[^].
The best things in life are not things.
|
|
|
|
|
Richard MacCutchan wrote: A simple Google search yields
google is cure for every programmer disease
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
ThatsAlok google is cure for every programmer disease
Yeah that would be nice! But seriously, I continue to be amazed by the number of questions here where people just cannot be bothered to make a first attempt to research the background to their problem, but just post "How can I do ... ?". In most cases it takes less time to Google than it does to post a question.
The best things in life are not things.
|
|
|
|
|
Couldn't agree more. Apparently CP takes exception to me trying to 5 vote something more than once..
If I had a dollar for the number of times that a question could be answered simply by searching google for an exerpt of the original post, I'd 'work' from 9:30 - 11:30 in the morning and make more than I do currently!
|
|
|
|
|
The best things in life are not things.
|
|
|
|
|
right you say
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
You can utilize the CImageList[^] for MFC to drag and drop images. If you're not using MFC, you can still use the image list API. The API's will supply the visual goodies when dragging an image.
|
|
|
|
|
When I run my program I got:
Debug Assertion Failed!
Program: F:\Debug\abvb.exe
File: dbgheap.c
Line:1044
Expression: _CrtIsValidHeapPointer(pUserData)
Please give me a direction on how to find the problem.
Thanks
|
|
|
|
|
As you are getting assert failure, this is for sure that you are using running build of your project. The _CrtIsValidHeapPointer() checks whether the specified address is valid within the local heap. The assert indicates that pUserData doesn't lie in the local heap address space. That may be because, pUserData is not allocated yet or is holding invalid address. It would helpful if you post the full code/function where you get the assert.
For more information, have a look at CRT Debugging Techniques[^].
|
|
|
|
|
You just used an invalid pointer. Have a look at the Call Stack window in Visual Studio IDE to locate the offending code.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Call stack is the best option in this case...
|
|
|
|
|
When I get this problem it's usually due to trying to deallocate a pointer that already has been deallocated. Look at the call stack to find out which object you're trying to deallocate, then check why it's been deallocated already.
If this is not called during deallocation then I have no idea, sorry.
|
|
|
|
|
Thanks for all guys who made suggestion above. When I debug I got error message:
"user break point called from code at 0x7c90120e"
-> 7C90120E int 3
Please help,
Thanks
|
|
|
|
|
You haven't mentioned what tools you use to develop and debug, but if you got a debugger running, it should automatically open the source code at the position where the error occurs. The message however sounds like it's from internal code, so, most likely, you won't recognize the code as yours.
You now need to find out where in your code this function was called. For that you need to check the call stack. If no window is shown for it, see if you can activate it from the menu. If you don't know how to do this, check the help function from your development environment.
Once you have the call stack, the focus will likely be on the topmost line, indicating the function that is shown in your source code window. Usually you can make an educated guess what kind of functionality should be performed here from the name of the function. I still suspect you're inside some deallocation routine, but it may be something different; check this!
Now scan down the list in the call stack and find the first function that you recognize as part of your own source code. Doubleclick it or do whatever is required to navigate to that position. The source code window will then show the exact location in your source code where another function not from your source code is called. If the problem occurs during deallocation it may be tricky though, as the call may in fact occur at the end of a scope, where stack variables are destroyed. In that case the cursor in the code window may point to a line past the end of the scope; this can be a bit confusing at times...
Anyway, once you've located the right location in your code, check the values of the parameters that are involved in the function (or deallocation) call, and see if they have values in the range you expect. Again, if this a deallocation problem, you may not see anything unusual amiss - in this case, if you don't know how to proceed, copy some of the code at that location and post it here.
|
|
|
|