Page 1 of 1
Fast collections and Java collections
Posted: Wed May 07, 2014 9:28 pm
by KaL
Hello!
I've seen discussions about Javolution being overused in the project and I'd like to have some more info about this.
In which situations javolution collections are more suitable and which not?
Also, what's the difference between using it in shared mode and using Concurrent java colletions?
Thank you

Re: Fast collections and Java collections
Posted: Wed May 07, 2014 10:39 pm
by UnAfraid
One of differences is that FastMap keeps its elements sorted by the way you've stored them, but ConcurrentHashMap doesn't it keeps them randomly sorted.
Also we are replacing javolution at the places that we can use native java concurrent collections.
Re: Fast collections and Java collections
Posted: Wed May 07, 2014 11:08 pm
by KaL
UnAfraid wrote:
Also we are replacing javolution at the places that we can use native java concurrent collections.
Thanks for the reply.
But what's the criteria for this replacement?
Re: Fast collections and Java collections
Posted: Thu May 08, 2014 9:50 am
by UnAfraid
KaL wrote:UnAfraid wrote:
Also we are replacing javolution at the places that we can use native java concurrent collections.
Thanks for the reply.
But what's the criteria for this replacement?
Most of FastMaps can be safely replaced with ConcurrentHashMap (Of course where sorting doesn't matters) but some FastLists cannot be replaced with CopyOnWriteArrayList for example due to some issues for example i've replaced the lists in Olympiad that holds participants and i end up into a problem having players 'unregistered' but they wasn't or player registered into few fights at the same time and stuff like that.
Re: Fast collections and Java collections
Posted: Thu May 08, 2014 10:59 am
by jurchiks
That's not really a proper answer to his question...
I'm pretty sure he meant why do you choose to replace x with y, based on what criteria? Is it actually better in that specific scenario or you just like it that way?
Re: Fast collections and Java collections
Posted: Thu May 08, 2014 6:33 pm
by KaL
UnAfraid wrote:KaL wrote:UnAfraid wrote:
Also we are replacing javolution at the places that we can use native java concurrent collections.
Thanks for the reply.
But what's the criteria for this replacement?
Most of FastMaps can be safely replaced with ConcurrentHashMap (Of course where sorting doesn't matters) but some FastLists cannot be replaced with CopyOnWriteArrayList for example due to some issues for example i've replaced the lists in Olympiad that holds participants and i end up into a problem having players 'unregistered' but they wasn't or player registered into few fights at the same time and stuff like that.
I see, thank you
jurchiks wrote:I'm pretty sure he meant why do you choose to replace x with y, based on what criteria? Is it actually better in that specific scenario or you just like it that way?
Actually yes, I'd like to know better the cases I should choose between javolution and java libraries

Re: Fast collections and Java collections
Posted: Thu May 08, 2014 9:33 pm
by Hyrelius
I'd also like to know why one should use java-native maps and lists. Javolution suggests on their page, that their maps and lists are better and faster (at least in those cases they offer). So I'd also like to know why and when one should prefer one over the other.
Thanks in advance.
Re: Fast collections and Java collections
Posted: Thu May 08, 2014 9:58 pm
by Zoey76
Hyrelius wrote:I'd also like to know why one should use java-native maps and lists. Javolution suggests on their page, that their maps and lists are better and faster (at least in those cases they offer). So I'd also like to know why and when one should prefer one over the other.
Thanks in advance.
If I made a collection API, I'd like to believe it's better than what I'm leaving behind

Re: Fast collections and Java collections
Posted: Thu May 08, 2014 10:07 pm
by xban1x
Fast collections can be both concurrent and thread safe. While Java collections only have concurrent safety.
Re: Fast collections and Java collections
Posted: Thu May 08, 2014 10:17 pm
by Zoey76
xban1x wrote:Fast collections can be both concurrent and thread safe. While Java collections only have concurrent safety.
Please read the javadocs at oracle

Re: Fast collections and Java collections
Posted: Fri May 09, 2014 10:04 am
by jurchiks
Zoey76 wrote:If I made a collection API, I'd like to believe it's better than what I'm leaving behind

You don't think they have made tests to prove their code is faster?
Everyone knows that the Java collections are for general use, they're all-rounders, not particularly good at anything, but not all that bad either, while libraries like Javolution and Trove specialize and excel at something in particular (storing time or retrieval time, among other things).
Re: Fast collections and Java collections
Posted: Fri May 09, 2014 2:20 pm
by Zoey76
To properly answer the OP question, one must sit and review the source code from Javolution (included in our source) and the source code of Java itself (included in any JDK).
ConcurrentHashMap, one of many concurrent and thread-safe implementations,
has been completely rewritten in Java 8 to increase performance.
Added some reference documetnation.
I'll elaborate this post later, I have to go now.
Re: Fast collections and Java collections
Posted: Fri May 09, 2014 2:21 pm
by jurchiks
Still, there is bound to be some custom collection that is faster than the built-in one.
Re: Fast collections and Java collections
Posted: Fri May 09, 2014 5:27 pm
by Hyrelius
This brings me back to the question: how do I decide what to use

?