I have a
Map<Float, MyObject>
What is the best way to keep the map sorted according to the float?
Is SortedMap or TreeMap the best answer?
How do I use it?
I only create the map once and replace the MyObject frequently using myMap.put() and myMap.get().
I would use
TreeMap, which implementsSortedMap. It is designed exactly for that.Example:
See the Java tutorial page for SortedMap.
And here a list of tutorials related to TreeMap.