/**
* sort sites on y, then x, coord
* also change each site's _siteIndex to match its new position in the list
* so the _siteIndex can be used to identify the site for nearest-neighbor queries
*
* haha "also" - means more than one responsibility...
*
*/
public int CompareTo(System.Object obj) // XXX: Really, really worried about this because it depends on how sorting works in AS3 impl - Julian
{
Site s2 = (Site)obj;
int returnValue = Voronoi.CompareByYThenX(this, s2);
// swap _siteIndex values if necessary to match new ordering:
uint tempIndex;
if (returnValue == -1)
{
if (this._siteIndex > s2._siteIndex)
{
tempIndex = this._siteIndex;
this._siteIndex = s2._siteIndex;
s2._siteIndex = tempIndex;
}
}
else if (returnValue == 1)
{
if (s2._siteIndex > this._siteIndex)
{
tempIndex = s2._siteIndex;
s2._siteIndex = this._siteIndex;
this._siteIndex = tempIndex;
}
}
return(returnValue);
}