I want to create my custom Hash Table for key with multiple values. For that, what I want to do is following:
1) Create an array of Linked Lists/ Array-list of the size
Integer_MAX.2) Insert values (int’s) to the Linked Lists/ Array-list whose number
is key number.
Now, I am facing two issues:
1) How to define array of Linked Lists/ Array-list’s.
2) Is there any way to make them primitive ?
Any help or any idea to make it better will be helpful to me.
Thanks.
Edit: I know that Hash Table concept has nothing to do with key with multiple values. But, I want to make it like that.
I want to make a custom hash map and for primitives (not for objects as it takes really huge space like guava).
1) You define an array of LinkedLists just like any array:
Although, you should probably do an array of Lists instead:
2) Arrays are not primitives. Neither are LinkedLists. Also, LinkedLists can only hold references, not primitive types. If you must store primitives in your custom hashmap class, you will need to use arrays only, not LinkedList or ArrayList.