how is hashmap internally implemented in java using linkedlist or array -
how hashmap internally implemented? read somewhere uses linked list while @ places mentioned arrays.
i tried studying code hashset , found entry array , linkedlist used
it looks this:
main array ↓ [entry] → entry → entry ← here linked-list [entry] [entry] → entry [entry] [null ] [null ]
so have main array each index corresponds hash value (mod
'ed* size of array).
then each of them point next entry same hash value (again mod
'ed*). linked-list comes in.
*: technical note, it's first hashed different function before being mod
'ed, but, basic implementation, modding work.
Comments
Post a Comment