3 ms·
Solved by libraries such as Eclipse collections: https://www.baeldung.com/java-eclipse-primitive-collections https://www.baeldung.com/java-eclipse-primitive-col
by lenkite 4y ago
Solved by libraries such as Eclipse collections: https://www.baeldung.com/java-eclipse-primitive-collections https://www.baeldung.com/java-eclipse-primitive-collections which has memory-optimized lists, sets, stacks, maps, and bags for all the primitive types
- Someone 4y agoI wouldn’t call that solved, but improved. Programmers will have to do extra thinking and work to get those benefits, code reviews may spend hours discussing whether making the switch is worthwhile. And that’s not one-time work. In the ideal world, if the size of your data grows (or shrinks), you’ll have to revisit those choices. Also, as a library author, you can’t know what choice to make. Yes, you’ll always have that problem, but this change would make ‘just use the provided collections’ a much safer choice.
- rockwotj 4y agoAlso a lot of types like this fall back to boxing when accessed generically, which has its own performance issues
- kjeetgill 4y agoI disagree. In general once you have a primitive specialized library kicking around in your path, you can pretty much just always use it for anything with primitive keys no questions asked. You don't have to over-optimize by deciding which one each time. Usually you just pick fastuil or kobloke and then use it every time. Edit: as comments below corroborate.