Possible Duplicate:
Bidirectional multi-valued map in Java
I need a data structure that implements a N-to-N relation. Something like a Map<Foo,Bar>
with calls:
getValues(Foo foo): Collection<Bar>
getValues(Bar bar): Collection<Foo>
and methods for the usual management like:
removeKey(Foo) [remove all the <Foo,X> entries]
removeValue(Bar) [remove all the <X,Bar> entries]
Is there some library I can use or should I implement it? Thanks