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)
|
||||
{
|
||||
int result = _renderOrder - other._renderOrder;
|
||||
// if render order is same, use their natural order
|
||||
return (result != 0) ? result : naturalOrder() - other.naturalOrder();
|
||||
return (result != 0) ? result : naturalCompareTo(other);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -345,13 +344,13 @@ public abstract class AbstractMedia
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value used to "naturally" order media within the same render order layer. The
|
||||
* default behavior, for legacy reasons is {@link #hashCode} which is not consistent across
|
||||
* sessions.
|
||||
* "Naturally" compares this media with the specified other media (which by definition will
|
||||
* have the same render order value). The default behavior, for legacy reasons, is to compare
|
||||
* 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