[Biojava-dev] SortedMap comparator question

Michael L. Heuer heuermh@acm.org
Tue, 15 Oct 2002 12:38:36 -0400 (EDT)


So it's not perfect, but it seems to work.

> http://shore.net/~heuermh/set.tar.gz

I spent a lot of time trying to make the subSet views work like they do in
the Collections framework, but gave up and just return copies instead of
views.

After polishing, I may submit this to the jakarta-commons/collections
project, because they have a very complete test suite for collections
implementations.  If that doesn't fly then fitting it in biojava utils is
fine.

   michael


On Sun, 13 Oct 2002, Matthew Pocock wrote:

> Michael L. Heuer wrote:
> > On Wed, 9 Oct 2002, Thomas Down wrote:
> >
> >>How about defining a little datablob class which is an
> >>Object-double pair. defining a comparator over those, then
> >>just using a SortedSet?
> >
> >
> > I had thought about this, but the convenience of the keys and entrySet
> > views was desireable.
>
> I've done this before - with the pairs. It's east enough to write a set
> impl in terms of (Object,double) pairs and then write a set impl that
> deletagest to this for stoorage but projects the pairs back to just the
> Object.
>
> >
> > What I'm going for is something like
> >
> > interface ScoredSet extends Set (?)
> > {
> >   public double getScore(Object o);
> >   public double minScore();
> >   public double maxScore();
> >   public ScoredSet subSet(double fromScore, double toScore);
> > }
> >
> > and
> >
> > interface RankedSet extends ScoredSet
> > {
> >   public int getRank(Object o);
> >   public int minRank();
> >   public int maxRank();
> >   public RankedSet subSet(int fromRank, int toRank);
> > }
> >
> > providing
> >
> > 		score   rank
> > object1		100.0	1
> > object2 	90.0	2
> > object3 	90.0	2
> > object4		75	3
> >
> >
> > The Set contract is nice in that in that it provides for non-duplicate
> > elements, but it might not make sense to view this as a simple Collection
> > after all.
> >
>
> Good luck with this. If you do write this, then I'd love to see it in
> org.biojava.utils as it's a generaly usefull piece of kit to have lying
> arround.
>
> Best,
>
> Matthew
>
> >    michael
> >
> > _______________________________________________
> > biojava-dev mailing list
> > biojava-dev@biojava.org
> > http://biojava.org/mailman/listinfo/biojava-dev
> >
>
>
> --
> BioJava Consulting LTD - Support and training for BioJava
> http://www.biojava.co.uk
>
> __________________________________________________
> Do You Yahoo!?
> Everything you'll ever need on one web page
> from News and Sport to Email and Music Charts
> http://uk.my.yahoo.com
>