not sure if I should search or sort my hashmap

后端 未结 6 1610
北恋
北恋 2021-01-23 16:28

Hi I have a list of people with their ages, I need to find those who are more than 30 years old, is there any possibility to search in a hashmap ? (please note that I may need

6条回答
  •  醉话见心
    2021-01-23 16:52

    Good question... unfortunately, a Map needs a very specific key. Your solution above is the only real way to do it.

    Alternatively you could maintain two lists, and store those that older than 30 to the 2nd list.

提交回复
热议问题