Search code examples
javacollectionsapache-commons-collection

Order of elements in MultiKeyMap


Recently I started using Apache Commons MultiKeyMap for some of my projects and in there I can have multiple values for a value.

MultiKeyMap typePanelUnoMap = new MultiKeyMap();

I want to know whether we can preserve insertion order when using MultiKeyMap. I know that java.util.LinkedHashMap can preserve the insertion order.

Map hshmap = new LinkedHashMap()

Can I have the same functionality with MultiKeyMap?

Thanks,
Keth


Solution

  • from the javadocs

    This map is implemented as a decorator of a AbstractHashedMap which enables extra behaviour to be added easily.

    MultiKeyMap.decorate(new LinkedMap()) creates an ordered map.