0

我正在尝试创建一个 BiMap。

BiMap<Integer, Map<Item, Boolean>> rankedItem = HashBiMap.create();

            for (Catalogue catlogue : latestItemCataloug) {

                String name = catlogue.getName();

                List<Item> itemList = map.get(name);

                if (CollectionUtils.isNotEmpty(itemList)) {
                    itemList.stream().limit(max)
                            .peek(c -> c.setPrice(getPrice()))
                            .forEach(e -> {
                                Map<Item, Boolean> itemMap =
                                        new HashMap<>();
                                itemMap.put(e, true)
                                rankedItem.put(
                                        itemList.indexOf(e),
                                       );
                            });
                }
            }

它工作正常,但有没有更好的方法来做到这一点?我正在努力改进我的编码。请建议我如何优化此 Bi Map 创建?

4

0 回答 0