Just wanted to give u some infos about all that FastMap/TIntHashs.
We start with: FastMap
A FastMap is nothing else then an regular HashMap/THashMap, but has a big difference... all entries are LINKED!
Thats also the reason why FastMap iterations are much faster then iterating over an HashMap or using forEach on THashMap.
Whats "setShared()" on FastMap?
This flag does 2 things:
1: The linked entries never loose it`s links to the prev/next entry which results in an "save" iteration while removing/adding values to an map.
2: It will self synchronized when adding/removing values, like "synchronized(map){map.put(key, value);}"
Ofc this synchronisation slows down the FastMap because it must enter the thread monitor when adding/removing values.
Well Trove is not far away form the Java originals (in basics) but as u know it use primitive datatypes as key/value. So far u need to sync every access to the map if u don`t want urgend exceptions or fails. ReentrantReadWriteLock is ur friend again.
When to use Trove, Java, Javolution?
Code: Select all
using:THashMap<Integer, Object>TIntObjectHashMap<Object>FastMap<Integer, Object>HashMap<Integer, Object> Put (already in map)THashMap: 204%TIntObjectHashMap: 89%FastMap: 198%HashMap: 100% PutIfAbsent (already in map)THashMap: 160%TIntObjectHashMap: 45%FastMap: 100%HashMap: - Get (in map)THashMap: 189%TIntObjectHashMap: 49%FastMap: 137%HashMap: 100% Get (not in map)THashMap: 295%TIntObjectHashMap: 50%FastMap: 139%HashMap: 100% ContainsKey (in map)THashMap: 177%TIntObjectHashMap: 34%FastMap: 136%HashMap: 100% ContainsKey (not in map)THashMap: 292%TIntObjectHashMap: 39%FastMap: 145%HashMap: 100% ContainsValue (in map avg)THashMap: 143%TIntObjectHashMap: 150%FastMap: 57%HashMap: 100% ContainsValue (not in map)THashMap: 123%TIntObjectHashMap: 142%FastMap: 85%HashMap: 100% IterateTHashMap: 92%TIntObjectHashMap: 113%FastMap: 35%HashMap: 100%
As u can see Trove is ONLY suitable for primitives!
So if u have to iterate more often or do not have an primitive as a key use Javolution.
And now about the lists....
FastList is an LINKED list. If u know the final size of the list or now that u have to add more then > 8 entrys an ArrayList is faster (even with expand)!!! Specialy those cases where u fill into FastList and use toArray()!!!
Hopefully this will help u somehow.