Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java - Custom Hash Table

Tags:

java

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).

like image 378
Arpssss Avatar asked Feb 27 '26 12:02

Arpssss


1 Answers

I would highly recommend using a Multimap from the guava project. You can use an ArrayListMultiMap and get exactly the behavior you're looking for.

like image 62
Mike Deck Avatar answered Mar 01 '26 01:03

Mike Deck



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!