Open victornoel opened 5 years ago
It would be nice to have asMap, asList, asSet, etc. for primitive collections.
This was functionality that was in the process of being added for primitive Lists and Sets. I don't think the work was ever completed. While it is straight forward, it is a lot of work. Support needs to be provided for Iterators, etc. Decisions need to be made on whether to support both read and write apis.
I noticed the following need when manipulating primitive maps, but this apply to any primitive collection I believe, mutable and immutable alike.
Basically, I have a
MutableObjectDoubleMap<T>
and sometimes I need somewhere aMutableMap<T, Double>
.Currently what I would do is:
map.keyValuesView().toMap(ObjectDoublePair::getOne, ObjectDoublePair::getTwo))
The problem with this is that it involves useless copying.
I would have liked to be able to write:
map.asMap()
and get aMutableMap
view on my primitive map that boxes and unbox the values as needed depending on the operations used.