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
3
votes
2 answers

How to combine Map values from parent Map with java 8 stream

I have a map inside a map which looks like this: Map> mapInMap; //--> with values like: /* "a": (1: BigDecimal.ONE), "b": (2: BigDecimal.TEN), "c": (1: BigDecimal.ZERO) */ And I would like to combine the inner maps…
victorio
  • 6,224
  • 24
  • 77
  • 113
3
votes
1 answer

Efficient way to iterate over each key exactly once in unordered_multimap

I have a std::unordered_multimap and I want to iterate over each key exactly once. What I'm currently doing is copying all keys into a std::set. This seems rather inefficient to me and I'm wondering if there is a smarter way of doing this. If it…
pekkas
  • 31
  • 5
3
votes
2 answers

Convert multimap to void pointer and then back to multimap

I need to convert multimap into a void buffer, and pass it into a function where the multimap should be reconstructed. I know there is easy way to simply pass the multimap, but I need to do via the void pointer so please look at my logic…
mhibert
  • 67
  • 6
3
votes
2 answers

Error when using RestTemplate - problem with deserialization of object with Apache Commons Multimap

I am trying to retreive using RestTemplate object from service. HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); headers.setContentType(MediaType.APPLICATION_JSON); …
Real
  • 33
  • 3
3
votes
2 answers

Custom compare function for std::multimap when keys are equal

I would like to code a custom comparator for a std::multimap. What I would like to do is to compare the keys, in case they are equal, then compare the values. I'm trying to do it by overloading the operator() in a struct and passing the function…
Jules
  • 134
  • 1
  • 10
3
votes
1 answer

Guice MapBinder with list values

I have a service which needs injection of mulitmap - Map> public class EnrichService { private Map> typeEnrichers; @Inject public EnrichService(Map> typeEnrichers) { …
agav
  • 275
  • 1
  • 2
  • 10
3
votes
1 answer

Need to speed up C++ code involving Boost multi-index and lookups to unordered_multimap

I'm looking for strategies to speed up an agent-based model that's based on objects of class Host, pointers to which are stored in a Boost multi-index container. I've used Shark to determine that the vast majority of the time is consumed by a…
Sarah
  • 1,614
  • 1
  • 23
  • 37
3
votes
3 answers

Is There a way to Find the Number of Keys in a multimap Inline?

A multimap's size reports the number of values it contains. I'm interested in the number of keys it contains. For example, given multimap foo I'd like to be able to do this: const auto keyCount = ??? One way to get this is to use a…
Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288
3
votes
2 answers

How to populate entries into a map from a different thread and then from a single background thread iterate the map and send?

I have a below class in which I have a add method which is called by another thread to populate my clientidToTimestampHolder multimap. And then in the same below class, I start a background thread which runs every 60 seconds and calls a…
user1234
  • 145
  • 1
  • 12
3
votes
1 answer

Bukkit - Why is my Multimap not being passed?

So, I have a class called HitDistanceRatios, it Implements CommandExecutor, It's called in MainClass which is the only class that calls JavaPlugin except for ConfigGets. I also have another class called HitEvent which is an EventHandler, every time…
Kaelinator
  • 360
  • 3
  • 17
3
votes
2 answers

Return value of multi-level generic type cannot be assigned to an extended type

I have this convenient method (which I have been using for many years without problems). It just converts a List to a Map, grouping them by a key attribute. To avoid unnecessary casting, I'm passing the key attribute as a String…
bvdb
  • 22,839
  • 10
  • 110
  • 123
3
votes
3 answers

Having a hard time using max_element (min_element also) on a multimap

I'm having a really hard time solving this problem. I want to find the max and min of my keys in my multimap (which happen to be objects of a class). By max and min I'm referring to my objects size member ONLY. I've made a comparator function, to…
hopittyhop
  • 119
  • 12
3
votes
5 answers

A multimap with good performance

In my code I have a map that is used heavily, several thousand times in a few seconds. Originally I had a TreeMap, but when testing with 9,000 entries I watched my old processor melt. And this needs to scale. So I moved to a HashMap and performance…
TheLQ
  • 14,830
  • 14
  • 69
  • 107
3
votes
1 answer

"Don't Care" fields in multiset keys

I have a compound data type like: struct Key { optional a; optional b; optional c; }; I also have a multiset, multiset. For example, it contains {1, 2, 3} {1, NULL, 3} {NULL, 2, 3} {NULL, NULL, 3} I want to get all…
Sadjad
  • 1,661
  • 2
  • 13
  • 20
3
votes
4 answers

Sorting multimap with both keys and values

I am tryin to sort a multimap that have set of pairs in it using standard sort function by writing a compare function for it, but I am getting some error in it. I am trying to sort the map with values and then again sort it with keys. Compare…
CVS
  • 491
  • 2
  • 4
  • 13