ok for "find all attr2 for a given attr1" with the return values sorted, i would use:
a map from attr1 -> a TreeSet of matching attr2 values.
The treeset will be sorted by the natural ordering of the attr2 values, but if you need a different ordering, you can write your own Comparator for it.
Another consideration is what to return from the get method ... some choices are: a collection, an iterator or an Attr2[].
hmmm now ive lost the original message ... i think you also wanted to be able to "find all attr2 for a given attr1" ... so you could use the same approach in reverse for that.
So your class would look something like:
public class Stuff {
private Map attr1ToAttr2 = new HashMap(); // unsorted
private Map attr2ToAttr1 = new HashMap(); // unsorted
public void add( Attr1, Attr2 );
public Iterator listAttr2( Attr1 );
public Iterator listAttr1( Attr2 );
}
Well thats how id do it anyway.
ps. Hi Jim