Guava:Table 三维数据结构
java guava    2018-08-31 23:56:07    0    0    0
cqc   java guava
Table
表格集合类,能够通过行和列定位到一个cell,也能通过行取得整行的数据或通过列取得整列的数据

supports a number of views to let you use the data from any angle, including
  • rowMap(), which views a Table<R, C, V> as a Map<R, Map<C, V>>. Similarly, rowKeySet()returns a Set<R>.
  • row(r) returns a non-null Map<C, V>. Writes to the Map will write through to the underlying Table.
  • Analogous column methods are provided: columnMap()columnKeySet(), and column(c). (Column-based access is somewhat less efficient than row-based access.)
  • cellSet() returns a view of the Table as a set of Table.Cell<R, C, V>. Cell is much like Map.Entry, but distinguishes the row and column keys.
Several Table implementations are provided, including:
  • HashBasedTable, which is essentially backed by a HashMap<R, HashMap<C, V>> (as of Guava 20.0, it is backed by a LinkedHashMap<R, LinkedHashMap<C, V>>).
  • TreeBasedTable, which is essentially backed by a TreeMap<R, TreeMap<C, V>>.
  • ImmutableTable, which is essentially backed by an ImmutableMap<R, ImmutableMap<C, V>>. (Note: ImmutableTable has optimized implementations for sparser and denser data sets.)
  • ArrayTable, which requires that the complete universe of rows and columns be specified at construction time, but is backed by a two-dimensional array to improve speed and memory efficiency when the table is dense. ArrayTable works somewhat differently from other implementations; consult the Javadoc for details.

上一篇: Guava:Multimap 一个key映射多个值

下一篇: Guava:Bimap 双向映射

文档导航