google / guava

Google core libraries for Java
Apache License 2.0
50.14k stars 10.89k forks source link

BiMapBuilder to create a bimap with customized behavior e.g. insertion-order #130

Open gissuebot opened 9 years ago

gissuebot commented 9 years ago

Original issue created by nimrod.priell on 2009-03-12 at 08:19 AM


I think this is one very strong class in the API and you made it package viewable only. So I can't for example build a BiMap backed by my own map implementations or some standard java impl. like LinkedHashMap for insertion-order iteration.

gissuebot commented 9 years ago

Original comment posted by kevinb9n on 2009-03-12 at 06:39 PM


It's always been a future possibility, but designing and documentation for inheritance is a painful, very time-consuming activity and is not a priority for 1.0.

Bear in mind that ImmutableBiMap is insertion-ordered, and that insertion-ordered mutable bimaps can be kind of confusing because their key set and value set don't iterate in the corresponding order.

gissuebot commented 9 years ago

Original comment posted by jared.l.levy on 2009-03-12 at 06:43 PM


Instead of making StandardBiMap public, we could instead create a BiMaps.newBiMap() method that takes backing maps as input parameters. That approach avoids problems that arise when collection classes are publicly extendable.

We currently don't have that method because, until now, nobody has asked for it.

gissuebot commented 9 years ago

Original comment posted by kevinb9n on 2009-03-12 at 06:46 PM


Actually, we used to have it, for a long time, internally, and then we noticed that of the few people who used it, none of them were actually getting the benefit from it they thought they were. We decided after giving it a chance that this was not very useful, and we got rid of it.

gissuebot commented 9 years ago

Original comment posted by jared.l.levy on 2009-03-12 at 06:48 PM


Correction: Maps.newBiMap()

gissuebot commented 9 years ago

Original comment posted by kevinb9n on 2009-09-12 at 02:14 AM


(No comment entered for this change.)


Labels: post-1.0

gissuebot commented 9 years ago

Original comment posted by kevinb9n on 2009-09-12 at 02:15 AM


Issue #235 has been merged into this issue.

gissuebot commented 9 years ago

Original comment posted by kevinb9n on 2009-09-17 at 05:45 PM


(No comment entered for this change.)


Labels: -post-1.0, Milestone-Post1.0

gissuebot commented 9 years ago

Original comment posted by kevinb9n on 2009-09-17 at 05:57 PM


(No comment entered for this change.)


Labels: Type-Enhancement

gissuebot commented 9 years ago

Original comment posted by kevinb9n on 2009-10-30 at 04:00 PM


Issue #283 has been merged into this issue.

gissuebot commented 9 years ago

Original comment posted by kevinb@google.com on 2010-07-30 at 03:53 AM


(No comment entered for this change.)


Labels: -Milestone-Post1.0

gissuebot commented 9 years ago

Original comment posted by fry@google.com on 2011-01-26 at 09:50 PM


(No comment entered for this change.)


Status: Accepted

gissuebot commented 9 years ago

Original comment posted by kevinb@google.com on 2011-07-13 at 06:18 PM


(No comment entered for this change.)


Status: Triaged

gissuebot commented 9 years ago

Original comment posted by fry@google.com on 2011-12-10 at 03:36 PM


(No comment entered for this change.)


Labels: Package-Collect

gissuebot commented 9 years ago

Original comment posted by fry@google.com on 2012-02-16 at 07:17 PM


(No comment entered for this change.)


Status: Acknowledged

gissuebot commented 9 years ago

Original comment posted by kevinb@google.com on 2012-05-30 at 07:43 PM


(No comment entered for this change.)


Labels: -Type-Enhancement, Type-Addition

gissuebot commented 9 years ago

Original comment posted by kevinb@google.com on 2012-06-22 at 06:16 PM


(No comment entered for this change.)


Status: Research

gissuebot commented 9 years ago

Original comment posted by lowasser@google.com on 2012-11-07 at 08:21 PM


Issue #1195 has been merged into this issue.

gissuebot commented 9 years ago

Original comment posted by amend6 on 2013-01-10 at 02:02 PM


Related to this I want to extend the RegularImmutableBiMap, but there is no public class access.

gissuebot commented 9 years ago

Original comment posted by lowasser@google.com on 2013-01-10 at 05:01 PM


The immutable collections can definitely not be extensible. That's part of Effective Java item 15 -- immutable classes cannot be extended.

kluever commented 9 years ago

We're considering making HashBiMap insertion ordered by default, but there still may be value in having a BiMapBuilder (similar to MultimapBuilder).

kevinb9n commented 9 years ago

We're kicking around a design like this

How much interest is there in this?

So each direction might maintain its own separate iteration order, but if one side is plain "hash" then it should probably just reuse the iteration order of its inverse, since anything's better than arbitrary order.

bojanv55 commented 7 years ago

Nobody needed this since 2015?