Questions tagged [multimap]

A container similar to a map but allowing duplicate keys

Use this tag for questions about associative arrays with non-unique keys, such as the std::multimap container in the C++ standard library, or scala.collection.mutable.MultiMap in Scala.

See the Wikipedia article for more information.

773 questions
-1
votes
1 answer

How to sort std::multimap entries based on keys and values via custom Compare predicate?

I'm looking for a way to sort std::multimap's entries in ascending order by keys, but if the keys match, in descending order by values. Is it possible to implement with a custom Compare predicate?
-1
votes
1 answer

what is the time complexity and space complexity of this solution? Question- Top K Frequent Elements (Leetcode-Medium)

vector topKFrequent(vector& nums, int k) { if(k==nums.size()) return nums; map mp; for(int i=0;i m; for(auto& it:mp){ …
-1
votes
1 answer

Inserting a struct as a value in Multimap and Iterating the same to get the values

#include #include struct temp { int x; int id; }; int main() { temp t; int key; typedef std::multimap mapobj; t.x = 10; t.id = 20; key=1; mapobj.insert(pairkey,t); …
-1
votes
1 answer

Can multimaps be implemented with structures as key? If yes then how?

For example two structures like point and square as given below if it is possible to do so how may i insert new elements into it? typedef struct _point{ int x; int y; }Point; typedef struct _square{ float belowLeftX; float…
Ali Akber Faiz
  • 117
  • 1
  • 12
-1
votes
2 answers

inserting into a multimap c++

I have been given a mutlimap typedef std::multimap wordDictType; in a class and I need to design a function that will insert a word and word length into the multi map. I know to traditionally insert into…
-1
votes
2 answers

Printing all elements of multimap, which are pair of 2 different objects in C++?

I have 2 classes A and B. I create objects which are then put into a multimap. I want to print the all the keys with their corresponding values. However, my attempt to do this was not so successfull as I could create an iterator. I would like to ask…
-1
votes
1 answer

Removing duplicates in multigroup

I'm trying to remove elements that have the same key and value in a multimap. This is my code for now. After deleting the element, I get exception. multimap m_StudentMap; void removeDuplicates() { for (auto it1 =…
user4317723
-1
votes
2 answers

Count duplicate values in Multimap

I have Multimap. Example: 00254=[00255, 2074E, 2074E, 2074E, 2074E, 2074E, 2074E, 00010, 00010, 00010, 0006, 0006, 0006, 00010, R01018, R01018, 0006, 0006, R01018, R01018, R01018, 12062, S2202962, S2202962, R01018, 12062, 20466, 12062, 20466, 22636,…
torochi
  • 11
  • 5
-1
votes
1 answer

sort an object in descending order of one field

I have a multimap which will contain bunch of keys and values in it. private final Multimap processById = TreeMultimap.create(); Now for same key I can have bunch of Process so that's why I am using multimap here. Now I need to…
flash
  • 1,455
  • 11
  • 61
  • 132
-1
votes
1 answer

How can I make an unordered_multimap in C++ between an int and a pair?

When trying to run the following code I get this compiling error "error: type/value mismatch at argument 2 in template parameter list for ‘template class std::unordered_multimap’ unordered_multimap m;" Is there any way I can setup an multimap? If…
-1
votes
1 answer

How to add MultiMaps gradle to android

I want to use MultiMaps in my project because it allows to store duplicate key values. But the problem is with adding gradle. This is how i add: In my submodule gradle i add: compile 'com.google.guava:guava:21.0' Then I get a error saying to add…
Sindhu
  • 421
  • 1
  • 6
  • 16
-1
votes
3 answers

Does std::multimap::emplace overwrite old keys?

std::multimap mymap; mymap.emplace(1, "hello "); mymap.emplace(1, "world!"); std::cout << mymap.size() << "\n"; Will this echo 1 or 2? I.e., can I use emplace to add new pairs to a multimap, without affecting older pairs with the…
neckutrek
  • 353
  • 2
  • 14
-1
votes
1 answer

Importing ArrayListMultimap into IntelliJ - Java

I imported the Guava MultiMap library into IntelliJ but when i try to use the MultiMap interface Multimap> addBlock = new ArrayListMultimap.create(); the create is not activate. It is coloured in red. This is the…
Arthur Decker
  • 1,191
  • 3
  • 15
  • 45
-1
votes
1 answer

C++ How to insert in std::multimap?

How can i insert in std::multimap > ? I ll use it for storing data's player and ia, Is it the best container for this?
-1
votes
1 answer

Erasing all but one pairs in a multimap, using equal_range() and erase()

I've read a lot and couldn't find any answer to this issue. I have a multimap, which contains pairs of and using std::multimap.equal_range() I'm getting the range of all of the duplicate keys in it. The next step is that I…
meitriksx
  • 3
  • 2