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
Post a Comment