From 91c45db381dfe625088904ecf3e0ecae213c3b9f Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Tue, 15 May 2007 17:50:16 +0000 Subject: [PATCH] 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 --- src/java/com/threerings/media/AbstractMedia.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/java/com/threerings/media/AbstractMedia.java b/src/java/com/threerings/media/AbstractMedia.java index dd18fd5b..9cc5b13c 100644 --- a/src/java/com/threerings/media/AbstractMedia.java +++ b/src/java/com/threerings/media/AbstractMedia.java @@ -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(); } /**