Hi all!
The STL multimap accepts duplicate keys such that the following entry is valid for a multimap:
KEY VALUE
foo bar
jack jill
Now the problem is, multimap also accepts duplicate entries such that if I would add another foo, bar pair the multimap will accept it. So now my multimap might look like this:
KEY VALUE
foo bar
foo bar
jack jill
The question is, is there a short way to prevent insertion of VALUE duplicates?
The long way to do it is before a call to insert, I should iterate all those whose KEY is "foo" and if I find a VALUE that is the same, I will not insert it. This for me consumes too much CPU time if I have big data. So now I need a short way to do it.
Can anybody tell me or show me a short way of doing it?
Rome did not create a great empire by having meetings, they did it by
killing all those who opposed them.
- janvier -
The STL multimap accepts duplicate keys such that the following entry is valid for a multimap:
KEY VALUE
foo bar
jack jill
Now the problem is, multimap also accepts duplicate entries such that if I would add another foo, bar pair the multimap will accept it. So now my multimap might look like this:
KEY VALUE
foo bar
foo bar
jack jill
The question is, is there a short way to prevent insertion of VALUE duplicates?
The long way to do it is before a call to insert, I should iterate all those whose KEY is "foo" and if I find a VALUE that is the same, I will not insert it. This for me consumes too much CPU time if I have big data. So now I need a short way to do it.
Can anybody tell me or show me a short way of doing it?
Rome did not create a great empire by having meetings, they did it by
killing all those who opposed them.
- janvier -