Flattening a collection

前端 未结 9 2045
走了就别回头了
走了就别回头了 2020-11-30 02:55

Say I have a Map>

I can get the values of the map easily enough, and iterate over it to produce a single

9条回答
  •  心在旅途
    2020-11-30 03:25

    A nice solution for the subcase of a Map of Maps is to store, if possible, the data in Guava's Table.

    https://github.com/google/guava/wiki/NewCollectionTypesExplained#table

    So for instance a Map> is replaced by Table which is already flattend. In fact, the docs say that HashBasedTable, Table's Hash implementation, is essentially backed by a HashMap>

提交回复
热议问题