java - Iterating Through Treemap Ordered By Comparator -


i created treemap sorted value through comparator passed constructor.

how iterate through treemap in order created comparator? (not ascending value of keys/values)

you cannot treemap.

a workarround using linkedhashmap keep insertion order.
, want map sorted comparator, create an
instance of treemap comparator , put elements in contained in linkedhashmap.

map<myobject> linkedhashmap = new linkedhashmap<>(); .... treemap<myobject> treemap = new treemap<>(new mycomparator()); treemap.putall(linkedhashmap); 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -