Custom HashMap implementation

前端 未结 7 1871
挽巷
挽巷 2021-02-06 06:45

This question was asked to me in an interview. I think the only way to get best solution is SOF. So the question was \"How would you implement a custom HashMap in java(A

7条回答
  •  爱一瞬间的悲伤
    2021-02-06 06:46

    Look at Cliff Click's nonblockinghahmap for an example of a need for a hashmap implemented in java. Remember that an associated array is just another name for a hash map, so he's asking you how to implement it.

    Generally hashes are implemented using standard arrays (not lists or anything fancy for speed). The issue is what is inside each of these arrays... in the case of a hash collision do you want to use a LinkedList (chaining) or do you want to rehash and go to another array location (open addressing). Read some more computer science to learn the cost/benefit to doing both.

提交回复
热议问题