After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 663339 - MultiMap needs key_type and value_type members
MultiMap needs key_type and value_type members
Status: RESOLVED DUPLICATE of bug 663337
Product: libgee
Classification: Platform
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: libgee-maint
libgee-maint
Depends on:
Blocks:
 
 
Reported: 2011-11-03 17:40 UTC by Travis Reitter
Modified: 2011-11-03 18:07 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Travis Reitter 2011-11-03 17:40:35 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 ();
Comment 1 Maciej (Matthew) Piechotka 2011-11-03 18:07:00 UTC

*** This bug has been marked as a duplicate of bug 663337 ***