fragorl
fragorl

Reputation: 1736

Is there a SortedMultimap type implementation in Guava that doesn't care about the order of its values

E.g. I want a multimap from Integer to zero or more File objects. I'd like the map to stay sorted as I insert or remove entries. But I don't care about the order of the values (Files), which don't have a natural ordering anyway.

There doesn't seem to be an implementation that I can see (which is really unfortunate), so right now I'm stuck using TreeMap<Integer, List<File>>.

Upvotes: 4

Views: 370

Answers (1)

Daniel Pryden
Daniel Pryden

Reputation: 60967

MultimapBuilder should be able to do what you want:

SetMultimap<Integer, File> multimap =
    MultimapBuilder.treeKeys().hashSetValues().build();

Upvotes: 4

Related Questions