Find The Closest Answer in HashMap

前端 未结 6 1126
谎友^
谎友^ 2020-12-16 13:07

I want to search for a key in a hashmap and find the nearest one to that key!

    HashMap map = new HashMap();
         


        
6条回答
  •  误落风尘
    2020-12-16 13:44

    Not? That's not how the get function is supposed to work. I guess you might be able to use a TreeMap and use the getHeadMap/getTailMap and use some logic to find the closest match. But that would probably require to fiddle around a bit. After all what would the closest imply? ...

提交回复
热议问题