开发者

Collection.min Query For HashMap?

I have Declared a HashMap as

HashMap minMaxVal = new HashMap();

with K,V as Integer,Float[]

Would Like to retrieve the Min value from hashMap. Overriding the Min Function of collection is only solution for this scena开发者_如何学Pythonrio. How do I approach this.


Your Map<Integer, Float[]> can be converted to a Set<Map.Entry<Integer, Float[]>> using Map.entrySet(). Once you have this set, you can use Collections.min() to find the minimum value. Your comparator will have to decide how two Map.Entry<Integer, Float[]> instances compare.

I could have given you an example, but you didn't say what min meant in your case.


see this question : Get minvalue of a Map(Key,Double)

expecially see how to use a custom comparator, cause float[] is not directly (nor easily) comparable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜