|
Hi,
I am using multimap and key value can be duplicates.
I can find first key value using find() function.
But how to get next duplicate key value?
|
|
|
|
|
Which multimap implementation are you talking about?
|
|
|
|
|
I assume any standard compliant one will do.
Steve
|
|
|
|
|
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...
|
|
|
|