So I was reading about Java collections api's, and was wondering about HashMap put()
api, as per doc's it says its an constant time operations, but what confuses me is whether rehashing was taken into considerations as part of time complexity calculation or not.
ArrayList
add()
api on the other side clearly states its amortised o(n) i.e to add n element it will take n amount of time, why don't it applies to HashMap
put then? though HashMap
dynamically create bigger buckets upon reaching load factor, and re applies hash to existing entires to determine new bucket location.
any help on explaining above will be highly appreciated, let me know if this questions needed to moved to some other section, before down voting it.
Thanks.