A structure k => v
(k
and v
are >=0
ints) where all k
are unique while v
may be equal (k1 => v
and k2 => v
) should be sorted in ascending order of v
values, for example:
Let we have [35 => 1, 23 => 4, 9 => 9, 2 => 14]
and want to insert a new pair 20 => 5
, then the result is going to be [35 => 1, 23 => 4, 20 => 5, 9 => 9, 2 => 14]
.
What is the fastest structure in Java I can use in order to create it based on some input data and further iterate it in a 'one-by-one' fashion from the left. SortedHashMap
?