1

to のように、範囲インデックスにTreeBasedTable<String,String,CustomType>基づいてサブセットを取得できるようにする必要がある構造があります。メソッドは を返しません。これには何が最善のアプローチでしょうか?startendfromindextoindexcellSetSortedSet

やろうと思ったのですLists.newArrayList(structure.cellSet()).subList(start,end)が、あまり効率的ではないようです。

4

2 に答える 2

0

を使用するTreeBasedTableと、 の実装はrowMap()実際には を返しますSortedMap

したがって、次を使用する必要があります。

@SuppressWarnings("unchecked") // safe cast because TreeBasedTable returns SortedMap
final SortedMap<String, Map<String, CustomType>> rowMap = (SortedMap<String, Map<String, CustomType>>) myTable.rowMap();
final SortedMap<String, Map<String, CustomType>> subRowMap = rowMap.subMap(start, end);

sostartendは、 a で機能するのとrowMap同じようにsubList(start,end)機能しListます。

于 2013-08-28T21:54:26.357 に答える