1

Is there a built-in library or some other libraries which do the following hashmap implementation?

Let's suppose we want to add the following sets to be inserted as

1 2 3 4 5
1 3 5
1 2 4
2 3

I found if I had to go to just one level, I could use Multimap given in Multimap.

However, my requirement is as,

if I put using map, it should be something like,

1 -> 2 -> 3 -> 4 -> 5
       -> 4
  -> 3 -> 5
2 -> 3

So, if I have the key 1, it should put the next that comes with 1 into the same key value and then add 2 into the next level.

Is there implementation like this in java?

7
  • Why map and why not graph? Commented Oct 11, 2016 at 18:16
  • It looks like you're looking for a trie or a graph (depending on your needs). community.oracle.com/thread/2070706 or github.com/brianfromoregon/trie Commented Oct 11, 2016 at 18:17
  • I was hoping if I could reduce the computation time to read. I need to repetitively read from the this map and check if it is there or not. Commented Oct 11, 2016 at 18:29
  • what application are you applying this to? and why doesn't a simpler approach work, such as a list of sets? From my experience, it's usually better to keep things like I/O simple if possible Commented Oct 11, 2016 at 18:41
  • I implemented this with just arraylist and with binary search.....I am trying to find the possibility of whether I could reduce the computation time by applying the hashmap approach. Thank you...I appreciate the suggestions. Commented Oct 11, 2016 at 18:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.