java – Google Guava vs. Apache Commons

I was looking for a bidirectional map implementation in Java and came across these two libraries:

>Google guava (formerly "Google collections") > Apache common collections

Both are free, with the bi-directional map implementation I'm looking for (bidimap in Apache, bimap in Google), almost the same size (APACHE 493 KB, Google 499 KB) [edit: no longer true!] And it seems to be very similar to me in all aspects

Which one should I choose and why? Are there other equivalent alternatives (must be free and have at least two-way mapping)? I'm using the latest Java se, so I don't need to artificially restrict Java 5 or something like that

Solution

In my opinion, a better choice is guava (formerly known as Google Collection):

>It is more modern (generic) > it fully complies with the requirements of the collections API > it actively maintains > cachebuilder. Its predecessor mapmaker is great

Apache common collections is also a good library, but it has failed to provide a version that supports generics for a long time (in my opinion, this is the main disadvantage of the collection API) and usually seems to be maintaining / not doing the - too much work on it mode. Recently, common collections has gained some momentum again, but it has caught up with it

If download size / memory footprint / code size is a problem, Apache commons collections may be a better candidate because it is a common dependency of other libraries Therefore, using it in your own code can also be done without adding any other dependencies Editor: this special "advantage" has now been partially overturned because many new libraries actually rely on guava rather than Apache common collections

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>