3 ms·
I do hope I am wrong; but isn't this like creating a version of Map for every possible permutation of the primitive types? I.e. MapIntInt MapIntShort MapShortB
by chvid 12y ago
I do hope I am wrong; but isn't this like creating a version of Map for every possible permutation of the primitive types?
I.e. MapIntInt MapIntShort MapShortBool etc. because you cannot write Map<int, short> and somehow think that the overhead of boxing (Map<Integer, Short>) is unbearable.
- makeramen 12y agoYeah I'm confused here too, I understand there might be a need for some of these, but you should be able to just rely on autoboxing of primitives to Objects like what RxJava does: https://github.com/ReactiveX/RxJava/tree/1.x/src/main/java/rx/functions https://github.com/ReactiveX/RxJava/tree/1.x/src/main/java/r... I can maybe see an extra variation for exceptions, but that would be one more generic or a Set<? extends Exception> no?
- chvid 12y agoYes.
- BrandonM 12y agoIt's exactly like that. For some use cases, that cost matters. Trove is a popular project that does just what you describe for Set, List, and Map. For this library, if you stick to binary-core, you basically get what Java 8 provides out of the box, while also getting exception-throwing functional interfaces, static `unchecked` functions for concisely converting from checked to unchecked versions, and `bind` methods for providing currying operations. So the full type enumeration is one part of it, but there`s a little more to it than that. I probably could have done a better job touting the other benefits.