Jump to content

Talk:Multimap

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Several equal values to the same key

[edit]

It is unclear whether a multimap allows that the same value is stored with the same key more than once. So an insertion of (1,10), (1,10), (1,10) result in 1 element or 3 elements in the multimap. The std::multimap in C++ holds 3 elements after that. What about the other implementations? --RokerHRO (talk) 15:49, 21 September 2010 (UTC)[reply]

According to GCL, both alternatives are possible. Svick (talk) 17:58, 21 September 2010 (UTC)[reply]
Oh, that's bad. You referred a Java implementation, I asked especially for C++. I looked into the ISO C++ standard (2003 version) and they don't say anything about this topic. Is it clarified in C++0x? What about other languages that supports multimaps in their language core or their standard library? I think this topic is relevant enough to be mentioned in this article. What do you think? --RokerHRO (talk) 10:03, 22 September 2010 (UTC)[reply]
According to my reading of the C++ specification, C++ multimap allows multiple elements with the same key and value. (The code a_eq.insert(t) “inserts t and returns the iterator pointing to the newly inserted element”. That means it always inserts new element, no matter what is already in.)
Yeah, I think it's worth mentioning in the article. Svick (talk) 18:03, 22 September 2010 (UTC)[reply]