multimap

Requirement for key in std::multimap

I have a std::multimap where key is a custom class. Something like this: Class X { public: std::string s; int x; operator <(const X& other) const { return s < other.s; } }; std::multimap<X, int> mymap; Now, I'd like to use upper_bound and lower_bound to iterate over all elements with the same value of "s". Do I need to imp...

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}, {"Group1", 3}, {"Group2", 10}, {"Group2", 11}, {"Group2", 12} Having stored these values, ...

multimap in .NET

I need an equivalent to c++'s std::multimap<K, V, Comp, Alloc> in C-sharp. Does it exist in the standard library? ...

Can I continue to use an iterator after an item has been deleted from std::multimap<>?

Can I continue to use an multimap iterator even after a call to multimap::erase()? For example: Blah::iterator iter; for ( iter = mm.begin(); iter != mm.end(); iter ++ ) { if ( iter->second == something ) { mm.erase( iter ); } } Should this be expected to run correctly, or is the iterator invalidated f...

I need a slightly different multimap

Hi all, I'm looking for a C++ container class, that's a lot like a multimap, but slightly different. The container would store pairs of strings. But when I retrieve items from the container using key K, I want to find all the items where K begins with the item's own key. E.G. If I use key "abcde" I want to find items with key "adc" ...

Multimap in Hibernate

I need a collection that stores entries as key-value pairs (so I can look up values by a key), but I need one that allows multiple values to share the same key using hibernate ...

How to"adapt" functors to use with map/multimap?

I'm having difficulty in using std::for_each and other algorithms with a multimap, and want to know if someone could help me developing a functor that could pass the appropriate parameter to the "generic" functions. My specific problem with map/multimap is that their iterators evaluate to a std::pair instead of the contained value (I me...

Java priority queue

Java's priority queue is a data structure with O(log n) complexity for put (insertion) and O(log n) for poll (retrieval and removal of the min element). C++ STL's multimap has the same functionality but O(1) complexity for retrieval and removal of the min element (begin and erase). Is there an equivalent in Java ? ...

How to convert c++ std::list element to multimap iterator

Hello all, I have std::list<multimap<std::string,std::string>::iterator> > Now i have new element: multimap<std::string,std::string>::value_type aNewMmapValue("foo1","test") I want to avoid the need to set temp multimap and do insert to the new element just to get its iterator back so i could to push it back to the: std::list<m...

Create Weak Multimap with Google Collections

Is there an equivalent to the nice MapMaker for MultiMaps? currently i create the cache like this: public static Map<Session,List<Person>> personCache = new MapMaker().weakKeys().makeMap(); the whole point of MultiMap is to avoid the nested List Values. is there any way to construct the multimap with weak keys? ...

Concurrent multimap put and remove

This is a composed concurrent list multimap implementation. A lower-level implementation would be better, but more complex. Ignoring the O(n) removal in the sublist, is this the correct way to compose a ConcurrentMap and CopyOnWriteArrayList into a functional ConcurrentMultimap? Are there any unresolved data races? private final Concur...

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 entry. A good example is a histogram of supermarket items where you place each group of it...

Multi-valued hashtable in Java

Is it possible to have multiple values for the same key in a hash table? If not, can you suggest any such class or interface which could be used? ...

Dictionary class

is it possible to have multiple values for a single key in the java dictionary class?? ...

Map implementation with duplicate keys

I want to have 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 its easy to write your own Map that does this, but i would rather use some existing solution. Maybe something in commons-collections or google-collections? ...

Multimap output after copying from map

This program stores pairs in a map, counting the number of times a word occurs. The goal is to have the data sorted by number of occurences and output in value/string form. Obviously the normal map sorts by the string key, so I had to reverse it. To do this I read in words, and increment their values appropriately in a map. Then I cre...

how does the stl's multimap insert respect orderings?

I have some data which come with a integer index. I am continuous generating new data which needs to added to the collection of data I have, sorted by that index, at the same time I want to easily be able to go the start of the data and iterate through it. This sounds like std::multimap is just what I need. However, I also need data w...

C++ Find the number of elements in a range from an STL::multimap

I have a STL::multimap and I search it with equal_range to return an upper and lower bound. Can I find the number of elements in this range without iterating through them all and counting them one by one? #include <iostream> #include <map> using namespace std; int main () { multimap<int,int> mm; pair<multimap<int, int>::iterat...

primitive multimap in java with good (insert, iteration) performance characteristics

I'm doing some heavy processing (building inverse indices) using ints/ longs in Java. I've determined that (un)boxing of standard java.collections maps takes a big portion of the total processing time. (as compared to a similiar implementation using arrays, which I can't use due to memory constraints). I'm looking for a fast 3rd-part...

C++ find multiple keys from a std::multimap

I have a STL::multimap and I search to populate a std::list with value which key is duplicated. Can I find/insert to a std::list the value of elements for all key where count > 1 without counting them one by one? std::multimap<int, std::string> mm ; mm[0] = "a" ; mm[1] = "b" ; mm[0] = "c" ; mm[2] = "j" ; mm[2] = "k" ; std::list<std...