I seem to be using the wrong search terms for this in Google...
I have written a Generic Class for Many-To-Many Associations, but I\'m guessing this has already been don
Looks like Apache Commons Multimap might be useful.
EDIT: except it's one-to-many, not many-to-many. However, it still might be handy to use instead of your Map<T, List<S>>
and Map<S, List<T>>
, or as a reference.
So far, this is a less trivial question than I thought. The two Java Collections extensions I know of off the top of my head are the Google one mentioned by duffymo, and the Apache Commons Collections. Neither has a many-to-many map. In Google's terminology, it would be a BiMultiMap
; in Apache's, it would be a BidiMultiMap
or MultiBidiMap
.