DaveAKing / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Involution BiMap (map that is its own inverse) #1587

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
My guess is that we don't want this, but I'm filing the bug.

My next guess is that, even if we do want this, we might not want a special 
BiMap type for it. Rather, we might want a special BiMap builder.

I did a search of Google-internal code for patterns of any of the three forms:

    map.put(a, b);
    map.put(b, a);

    builder.put(a, b);
    builder.put(b, a);

    return builder.put(a, b).put(b, a);

(Search code is in internal CL 57081455; results, CL 57076720.)

I got 18 hits across 15 files. A few of those looked like possible coincidences 
(not the creation of a true involution BiMap). On the other hand, surely there 
are other users who construct involution BiMaps but don't add the pairs in this 
order. And maybe my search just missed some. Still, even if there are a hundred 
people doing this, I'm not sure it justifies its own type. (The one case that I 
wonder if it might be useful is if anyone needs to map a value to itself, but 
I'm not sure that that even comes up.)

Original issue reported on code.google.com by cpov...@google.com on 21 Nov 2013 at 11:26

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<issue id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:10

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:17

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:08