4

How to convert java.util.Map to fastutil.BigList?

BigList<Employee> empList= empMap.values().stream().collect(Collectors.toList());

praba
  • 1,074
  • 3
  • 17
  • 38

1 Answers1

8

I see that BigList is an interface that extends java.util.Collection. You can use Collectors.toCollection to collect to this type.

You'll have to choose a specific class that implement the BigList interface. For example:

BigList<Employee> empList = 
    empMap.values()
          .stream()
          .collect(Collectors.toCollection(ReferenceBigArrayBigList::new));

Of course, if the BigList implementation you wish to create has a constructor that accepts a Collection, you can simply instantiate it yourself and pass empMap.values() to it without using Streams.

Eran
  • 387,369
  • 54
  • 702
  • 768