Is there an already implemented data structure that I can use in order to assign to an object (in my case an Edge), an integer? I am reading a graph from a file , 10 mil vertices , 60 mil edges and I assign to each edge , a cost , using a map ( costs.put(e,cost) ).
I create the costs map in this way :
costs = new HashMap<Edge,Integer>();
The exception that it gives is :
java.lang.OutOfMemoryError: Java heap space
at java.util.HashMap.resize(Unknown Source)
at java.util.HashMap.addEntry(Unknown Source)
at java.util.HashMap.put(Unknown Source)
HashMap
that is more memory-efficient? – Brenzacomparable
and use aTreeMap
– BrenzaTreeMap
's nodes add more overhead than raw arrays inHashMap
, and both rely onMap.Entry
instances. – Freeze