简体   繁体   中英

MultiMap Table with Guava

Recently I have discovered Guava in all its wonder. I have come across 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 to do this or should I just go with Tabe<R, C, Map<T>> ?

As given by one of the project members, Louis Wasserman:

"Conceptual consistency" is not nearly as relevant to us as the metric of "utility times ubiquity." We can't put in the kind of investment that Multitable would require for the sake of a comparatively tiny number of users. For the same reason, we don't include a "three-keyed map," either.

That said, markaf, I can think of another solution for your specific case: use a normal Multimap, but combine the first two fields into a composite key. It doesn't sound like you need to view the rows or the columns of that table, you just want to look up on multiple keys at once.

[And further explains in a second post] Additionally, the composite-key approach generalizes to arbitrary numbers of fields, in contrast to your proposed Multitable interface, which only get you one extra field.

The complete discussion can be found on the Guava Library issue tracker .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM