-2

I want to create a hashmap with a set of keys which may vary between 7 and 10

Arun Kumar Dave
  • 121
  • 1
  • 4
  • 9
  • 3
    What is `MultiKeyMap`? What have you tried so far? – Bhesh Gurung Jul 18 '18 at 14:24
  • There should be no limit ... apart from the amount of heap space needed to represent that map, the keys and the values. You should be able to confirm that by reading the source code. – Stephen C Jul 18 '18 at 14:26
  • see https://stackoverflow.com/questions/3038392/do-java-arrays-have-a-maximum-size since `MultiKey` uses an array in the constructor – fantaghirocco Jul 18 '18 at 14:30
  • @StephenC I exported this library org.apache.commons.collections4.map.MultiKeyMap The maximum keys that can be configured is 5. Is there any way i can change that or any source which allows more than 5 keys? – Arun Kumar Dave Jul 19 '18 at 10:17

1 Answers1

1

What is the maximum number of keys that can be created with MultiKeyMap

If you are asking about org.apache.commons.collections4.map.MultiKeyMap, then (as you noted) the current implementation is limited to 5 keys.

If you want to support more than 5 keys, then you can:

  1. download / copy the source code for the class,
  2. modify it to support up to 10 keys1,
  3. change the package name (to avoid getting into problems with conflicting versions), and
  4. add the modified class to your code base.

You can find the source code using Google.

If you are asking us to find you a library where someone has already done this, then I'm sorry but your Question is off-topic.


1 - If you look at the code, you will see that the required changes are simple.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216