keth
keth

Reputation: 825

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

Upvotes: 0

Views: 1409

Answers (2)

KushkiN
KushkiN

Reputation: 1

Since Apache Commons Collections 4, method multiKeyMap is being used instead of method decorate.

So it should be:

MultiKeyMap<String, Object> multiKeyMap= MultiKeyMap.multiKeyMap(new LinkedMap<>());

Upvotes: 0

Ajay George
Ajay George

Reputation: 11875

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.

Upvotes: 2

Related Questions