0

I am trying to create a 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),
                                       );
                            });
                }
            }

It works fine but Is there a better way to do this? I am trying to improve my coding. Please suggests how can I optimize this Bi Map creation?

user3407267
  • 1,524
  • 9
  • 30
  • 57
  • 3
    What exactly are you intending here? It's not clear why you are using BiMap. Are you trying to look it up based on the `Map`?! – Louis Wasserman Apr 25 '17 at 19:19
  • 3
    I'm voting to close this question as off-topic because I think that [Stack Exchange Code Review](https://codereview.stackexchange.com/) would be a better place for it. – Bobulous Apr 25 '17 at 19:40
  • 2
    (Are you looking for `Table`, rather than `BiMap`? `Table` is a map with two keys, `BiMap` is a map in both directions.) – Louis Wasserman Apr 25 '17 at 20:08

0 Answers0