HashMap resize method implementation detail

前端 未结 3 1962
傲寒
傲寒 2020-12-03 01:26

As the title suggests this is a question about an implementation detail from HashMap#resize - that\'s when the inner array is doubled in size. It\'s a bit word

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-03 02:05

    Order in a Map is really bad [...]

    It's not bad, it's (in academic terminology) whatever. What Stuart Marks wrote at the first link you posted:

    [...] preserve flexibility for future implementation changes [...]

    Which means (as I understand it) that now the implementation happens to keep the order, but in the future if a better implementation is found, it will be used either it keeps the order or not.

提交回复
热议问题