Поскольку вам явно требуется Map<Integer, Map<String, Integer>>
, вы можете сделать это в два этапа.
сначала соберите значения карты в список:
List<Map<String, Integer>> temporaryResult = new ArrayList<>(myMap.values());
затем создайте индекс вместе с картами:
Map<Integer, Map<String, Integer>> resultSet =
IntStream.range(0, temporaryResult.size())
.mapToObj(i -> new AbstractMap.SimpleEntry<>(i,
temporaryResult.get(i)))
.collect(Collectors.toMap(AbstractMap.SimpleEntry::getKey,
AbstractMap.SimpleEntry::getValue));
или без сопоставления с промежуточным звеном AbstractMap.SimpleEntry
'
Map<Integer, Map<String, Integer>> resultSet =
IntStream.range(0, temporaryResult.size())
.boxed()
.collect(Collectors.toMap(Function.identity(),
temporaryResult::get));