GNOME Bugzilla – Bug 663339
MultiMap needs key_type and value_type members
Last modified: 2011-11-03 18:07:00 UTC
AbstractCollection<T> has a useful public data member: Type element_type = T.get_type (); (get_type() above only works for objects, but you get the idea) This makes it possible to handle AbstractCollections in an extra-generic way like: /* note that we don't specify the generic type for ac */ void some_func (AbstractCollection ac) { if (ac.element_type == typeof (string)) handle_string (); else if (ac.is_a (typeof (SomeInterface)) handle_some_interface (); else if (ac.element_type == typeof (Object)) handle_plain_objects (); else ... } However, MultiMap doesn't derive from AbstractCollection, so it doesn't have element_type. So to do the equivalent of above, it's necessary to first do: var multi_map_keys = prop_value_multi_map.get_keys (); var key_type = multi_map_keys.element_type; var multi_map_values = prop_value_multi_map.get_values (); var value_type = multi_map_values.element_type; At least in the values case, this allocates a new ArrayList, iterates all the values, and various other things that add unnecessary computation. So, please add the following members to MultiMap/AbstractMultiMap/HashMultiMap: Type key_type = K.get_type (); Type value_type = V.get_type ();
*** This bug has been marked as a duplicate of bug 663337 ***