MultiMap table with Guava

I recently discovered Guava in all its amazement. I met an instance where I would like to use a combination of Multimap and Table, basically a Multimap with two keys.

Is there a Guava class for this or should I just go with Tabe<R, C, Map<T>> ?

+4
source share
1 answer

According to one of the project members, Louis Wasserman:

“Conceptual coherence” is not as important to us as the metric of “ubiquity of utility”. We cannot make such investments that Multitable will require for the sake of a comparatively tiny number of users. For the same reason, we do not include a “three-digit card.”

However, markaf, I can think of another solution for your specific case: use the usual Multimap, but combine the first two fields into a composite key. It doesn't look like you need to look at the rows or columns of this table, you just want to find several keys at once.

[And further explained in the second post] In addition, the combined key approach generalizes to an arbitrary number of fields, unlike your proposed Multitable interface, which gives you only one additional field.

A full discussion can be found in the Error Log in the Guava library .

+8
source

Source: https://habr.com/ru/post/1485726/


All Articles