S
SimeonArgus
I need to sort a list of points, so I've considered using an
IComparable implementation. Should be easy, right? But I need to know
two things in the CompareTo function, not one.
Test1: I need to know the distance in space from the "current point"
to the point sent in. This is what the current IComparable interfeace
gives me.
Test2 : I also need to know the distance in space from the "previous
point" to the point being sent in. HERE is my problem. How can I get
this?
Return the integer of (Test1 - Test2)
// Code version of the above statement in the class SpacePoint...
int IComparable<SpacePoint>.CompareTo(SpacePoint other)
{
int T1 = this.DistanceFrom( other );
int T2 = this.DistanceFrom( ??? );
return (T1 - T2);
}
The best, of course, would be to extend CompareTo to be
CompareTo(SpacePoint other, SpacePoint Prev)... but I can't think of a
clean way to do this. Any suggestions would be appreciated.
--Sim
IComparable implementation. Should be easy, right? But I need to know
two things in the CompareTo function, not one.
Test1: I need to know the distance in space from the "current point"
to the point sent in. This is what the current IComparable interfeace
gives me.
Test2 : I also need to know the distance in space from the "previous
point" to the point being sent in. HERE is my problem. How can I get
this?
Return the integer of (Test1 - Test2)
// Code version of the above statement in the class SpacePoint...
int IComparable<SpacePoint>.CompareTo(SpacePoint other)
{
int T1 = this.DistanceFrom( other );
int T2 = this.DistanceFrom( ??? );
return (T1 - T2);
}
The best, of course, would be to extend CompareTo to be
CompareTo(SpacePoint other, SpacePoint Prev)... but I can't think of a
clean way to do this. Any suggestions would be appreciated.
--Sim