Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert map to biglist?

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

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

like image 552
praba Avatar asked Jan 28 '23 06:01

praba


1 Answers

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.

like image 107
Eran Avatar answered Jan 29 '23 18:01

Eran