Map in Map in Guava

前端 未结 2 1971
醉梦人生
醉梦人生 2021-02-19 03:28

I have some code with Map> objects, which works (it is instantiated as a HashMap of HashMaps), but I wonder whether there is

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-19 04:22

    Take a look at Guava's Table interface.

    Its documentation example seems to overlap quite a bit with your use-case:

    Typically, when you are trying to index on more than one key at a time, you will wind up with something like Map>, which is ugly and awkward to use. Guava provides a new collection type, Table, which supports this use case for any "row" type and "column" type.

提交回复
热议问题