Is there a Many to Many Collection in Java using Generics (Domain Model, not Persistence Layer)?
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 done.  It is highly likely that it exists in an implementation much better than my own.  This is my first foray into writing a generic class.

For a better idea of what I'm looking for, I am including some snippets of my own:

I've backed it with 2 hashmaps:

    private final Map<T, List<S>> ssForTs = new HashMap<T, List<S>>();
    private final Map<S, List<T>> tsForSs = new HashMap<S, List<T>>();

Here is the instantiation:

    new ManyToManyAssociations<Integer, Integer>();
	
Some of the methods available:
<ul>
<li>public void addAssociation(T t, S s)</li>
<li>public void removeAssociation(T t, S s)</li>
<li>public List&lt;T&gt; getListOfTs()</li>
<li>public List&lt;S&gt; getListOfSs()</li>
<li>public List&lt;T&gt; getTsForSs(S s)</li>
<li>public List&lt;S&gt; getSsForTs(T t)</li>
</ul>

The names of the methods are quite poor... I apologize.

Basic usage is:
I can find all S for T and the reverse quite easily.

If anyone is interested in my particular implementation... I can append the code and the test for it.



Is there a Many to Many Collection in Java using Generics (Domain Model, not Persistence Layer)?
===

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 done.  It is highly likely that it exists in an implementation much better than my own.  This is my first foray into writing a generic class.

For a better idea of what I'm looking for, I am including some snippets of my own:

I've backed it with 2 hashmaps:

    private final Map<T, List<S>> ssForTs = new HashMap<T, List<S>>();
    private final Map<S, List<T>> tsForSs = new HashMap<S, List<T>>();

Here is the instantiation:

    new ManyToManyAssociations<Integer, Integer>();
	
Some of the methods available:
<ul>
<li>public void addAssociation(T t, S s)</li>
<li>public void removeAssociation(T t, S s)</li>
<li>public List&lt;T&gt; getListOfTs()</li>
<li>public List&lt;S&gt; getListOfSs()</li>
<li>public List&lt;T&gt; getTsForSs(S s)</li>
<li>public List&lt;S&gt; getSsForTs(T t)</li>
</ul>

The names of the methods are quite poor... I apologize.

Basic usage is:
I can find all S for T and the reverse quite easily.

If anyone is interested in my particular implementation... I can append the code and the test for it.


