Let's do this in a way that allows more than a single value to be used in the
natural comparison. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@249 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -170,8 +170,7 @@ public abstract class AbstractMedia
|
|||||||
public int compareTo (AbstractMedia other)
|
public int compareTo (AbstractMedia other)
|
||||||
{
|
{
|
||||||
int result = _renderOrder - other._renderOrder;
|
int result = _renderOrder - other._renderOrder;
|
||||||
// if render order is same, use their natural order
|
return (result != 0) ? result : naturalCompareTo(other);
|
||||||
return (result != 0) ? result : naturalOrder() - other.naturalOrder();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -345,13 +344,13 @@ public abstract class AbstractMedia
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a value used to "naturally" order media within the same render order layer. The
|
* "Naturally" compares this media with the specified other media (which by definition will
|
||||||
* default behavior, for legacy reasons is {@link #hashCode} which is not consistent across
|
* have the same render order value). The default behavior, for legacy reasons, is to compare
|
||||||
* sessions.
|
* using {@link #hashCode} which is not consistent across VM invocations.
|
||||||
*/
|
*/
|
||||||
protected int naturalOrder ()
|
protected int naturalCompareTo (AbstractMedia other)
|
||||||
{
|
{
|
||||||
return hashCode();
|
return hashCode() - other.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user