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
4
votes
1 answer

Indexing > using B-Tree

I am about to index 10 million titles with their IDs(for now their line numbers), titles will be stored after tokenising them. The structure of the data has to be something like >. Strings will represent the tokens,…
EurikaIam
  • 136
  • 9
4
votes
3 answers

order of elements in std::unordered_multimap

If I have the following piece of code std::unordered_multimap> myMap; std::vector v1, v2, v3; // init v1, v2, v3.... myMap.insert(std::make_pair("vec",…
djWann
  • 2,017
  • 4
  • 31
  • 36
4
votes
2 answers

A red black tree with the same key multiple times: store collections in the nodes or store them as multiple nodes?

Apparently you could do either, but the former is more common. Why would you choose the latter and how does it work? I read this: http://www.drdobbs.com/cpp/stls-red-black-trees/184410531; which made me think that they did it. It…
4
votes
2 answers

VC++11 map and multimap iterators (overloading) C2535

I'm just playing with new VS 2012 and I have a problem probably with new C++11. This pease of code work perfectly when I set platform toolset to VS2010 (v100) in project settings. .h: typedef std::multimap SizeMap; typedef…
Lipov3cz3k
  • 454
  • 4
  • 14
4
votes
3 answers

Remove only one element from multimap with duplicate keys

I have a multimap with Note objects from which I want to remove only one object. There can be several Note objects with the same key. The problem is that right now there's also objects being removed that aren't within the key range I specify: long…
user393964
4
votes
2 answers

Mutable MultiMap to immutable Map

I create a MultiMap val ms = new collection.mutable.HashMap[String, collection.mutable.Set[String]]() with collection.mutable.MultiMap[String, String] which, after it has been populated with entries, must be passed to a function that expects a…
Malte Schwerhoff
  • 12,684
  • 4
  • 41
  • 71
3
votes
2 answers

how to modify a value in multimap?

my question is that I have made multimap.Here is the partial code. if(binary_search(final.begin() , final.end() , answer ) ) { final[answer] = } else { …
InspiredCoder
  • 394
  • 6
  • 22
3
votes
4 answers

Objective-C implementation of a histogram or bag datastructure

Instead of implementing my own I was wondering if anyone knows of a histogram or bag datastructure implementation in Objective-C that I can use. Essentially a histogram is a hashmap of lists where the lists contain values that relate to their hash…
Michael Gaylord
  • 7,282
  • 8
  • 50
  • 47
3
votes
2 answers

Returning an iterator to a time in a multi-map that is closest to a specified time

Can someone suggest an elegant way to solve the following problem please? I have a multi-map keyed by time, and i wish to return the item that occured closest to a specified time T. In addition, the times searched within the map can only be an hour…
pingu
  • 8,719
  • 12
  • 50
  • 84
3
votes
2 answers

Skip same multimap values when iterating

Is there any good way to achieve the desired output below without having to remove the same values or creating another list/vector etc? I am trying to map words found in different documents to their document names as shown in the desired…
user629034
  • 659
  • 2
  • 11
  • 30
3
votes
3 answers

Filtering Guava HashMultimap keys by count

I have created a hash multi map of following type: key as a pair of string, string and value as long. HashMultimap, Long> hm = HashMultimap.create(); I have inserted some values in the table using put function. Now I want to…
user967491
  • 121
  • 1
  • 7
3
votes
1 answer

Threadsafe add operation for concurrent Multimap in Java

I want to have a concurrent multimap (a map from a key to a list of values) in Java, something like the following: var map = new ConcurrentHashMap>(); Is the following operation thread-safe, or is there a chance for a…
Wickoo
  • 6,745
  • 5
  • 32
  • 45
3
votes
1 answer

Paging and Join in Room

I want to use paging in room But I can not. Because I use multimap and it return map. When I use these technology together, I get this error : error: Not sure how to convert a Cursor to this method's return type Here is my code : @Query("SELECT *…
Javad Shirkhani
  • 343
  • 6
  • 11
3
votes
2 answers

Minimum of a matrix in C++

I have a std::vector> matrix, I insert elements of type T to this matrix and I do some instructions by line on these elements. I need also at each iteration to delete the element with a minimum cost. I created an…
user108724
  • 67
  • 9
3
votes
1 answer

Does emplace_hint on std::multimap preserves the relative ordering of equivalent elements?

According to http://www.cplusplus.com/reference/map/multimap/emplace_hint/ The relative ordering of equivalent elements is preserved, and newly inserted elements follow their equivalents already in the container. The value in position is used as…