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
294
votes
24 answers

Duplicate keys in .NET dictionaries?

Are there any dictionary classes in the .NET base class library which allow duplicate keys to be used? The only solution I've found is to create, for example, a class like: Dictionary> But this is quite irritating to actually…
waltersobchek.myopenid.com
136
votes
20 answers

Map implementation with duplicate keys

I want to have a map with duplicate keys. I know there are many map implementations (Eclipse shows me about 50), so I bet there must be one that allows this. I know it's easy to write your own map that does this, but I would rather use some existing…
IAdapter
  • 62,595
  • 73
  • 179
  • 242
104
votes
4 answers

What's the difference between std::multimap and std::map >

I found that they have one key and multiple values which is unique.
superK
  • 3,932
  • 6
  • 30
  • 54
90
votes
2 answers

What's the advantage of multimap over map of vectors?

I don't understand why multimap exists if we can create map of vectors or map of sets. For me only differences are: using equal_range in multimap for getting elements of a key and in map of vectors we simply use [] operator and have vector of…
Mariusz Pawelski
  • 25,983
  • 11
  • 67
  • 80
61
votes
10 answers

High-performance Concurrent MultiMap Java/Scala

I am looking for a high-performance, concurrent, MultiMap. I have searched everywhere but I simply cannot find a solution that uses the same approach as ConcurrentHashMap (Only locking a segment of the hash array). The multimap will be both read,…
Viktor Klang
  • 26,479
  • 7
  • 51
  • 68
52
votes
6 answers

multimap in .NET

I need an equivalent to c++'s std::multimap in C-sharp. Does it exist in the standard library?
Schildmeijer
  • 20,702
  • 12
  • 62
  • 79
52
votes
8 answers

How to create a Multimap from a Map>?

I didn't find such a multimap construction... When I want to do this, I iterate over the map, and populate the multimap. Is there an other way? final Map> map = ImmutableMap.>of( "1",…
sly7_7
  • 11,961
  • 3
  • 40
  • 54
45
votes
6 answers

is there an iterator across unique keys in a std::multimap?

Is there a simple or standard way to have a multimap iterator which iterate across unique keys in a multimap? i.e. for a set that looks like: {1, "a"}, {1, "lemon"}, {2, "peacock"}, {3, "angel"} an iterator which would start at {1, "a"} then…
Bingo
  • 3,785
  • 6
  • 23
  • 27
42
votes
3 answers

When does using a std::multimap make sense

I am currently experimenting on some usage of stl-datastructures. However I am still not sure when to use which one and when to use a certain combination. Currently I am trying to figure out, when using a std::multimap does make sense. As far as I…
LiKao
  • 10,408
  • 6
  • 53
  • 91
41
votes
7 answers

"multiset" & "multimap" - What's the point?

As the question states ... I don't get the point about multisets / multimaps. So, what's the purpose?
Sebastian
  • 8,046
  • 2
  • 34
  • 58
37
votes
6 answers

stl::multimap - how do i get groups of data?

Multimap essentially has groups of data sorted by the key. I want a method by which I could access these individual groups and get their aggregate values. For example, in a std::multimap< string, int > I store {"Group1", 1}, {"Group1", 2},…
the_Saint
  • 373
  • 1
  • 3
  • 4
33
votes
4 answers

How is the C++ multimap container implemented?

For example a C++ vector is implemented using a dynamic array where each element uses consecutive memory spaces. I know that a C++ multimap is a one to many relationship but what is the internal structure?
user656925
33
votes
2 answers

How to remove a specific pair from a C++ multimap?

#include ... multimap mymap; mymap.insert(pair('a',10)); mymap.insert(pair('b',15)); mymap.insert(pair('b',20)); mymap.insert(pair('c',25)); Say I now want to remove one of the pairs I have…
Jim Blackler
  • 22,946
  • 12
  • 85
  • 101
30
votes
4 answers

How to iterate through google multimap

I have to iterate through google multimap. But I am using jdk 1.4 and can't switch to higher version. So i can not use generic features. My multimap can have multiple values for a key. There might be a situation when a value of multimap is multimap…
Amit Kumar Gupta
  • 7,193
  • 12
  • 64
  • 90
28
votes
3 answers

How to eliminate duplicates in Guava MultiMap values?

Code: Multimap myMultimap = ArrayListMultimap.create(); myMultimap.put("12345", "qwer"); myMultimap.put("12345", "abcd"); myMultimap.put("12345", "qwer"); System.out.println(myMultimap); Result: {12345=[qwer,…
user710818
  • 23,228
  • 58
  • 149
  • 207
1
2 3
51 52