lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [41/58] [abbrv] lucenenet git commit: Implemented IComparable in Core.Util.Mutable.MutableValue, IComparable<T> does not automatically bring it along.
Date Thu, 10 Nov 2016 11:33:52 GMT
Implemented IComparable in Core.Util.Mutable.MutableValue, IComparable<T> does not automatically
bring it along.


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/fa5f4404
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/fa5f4404
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/fa5f4404

Branch: refs/heads/grouping
Commit: fa5f44047ccf406b17dd49530009007de0367462
Parents: f08a0e8
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Sat Nov 5 20:37:29 2016 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Tue Nov 8 02:24:56 2016 +0700

----------------------------------------------------------------------
 .../Util/Mutable/MutableValue.cs                | 26 +++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fa5f4404/src/Lucene.Net.Core/Util/Mutable/MutableValue.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Mutable/MutableValue.cs b/src/Lucene.Net.Core/Util/Mutable/MutableValue.cs
index 66334b3..d4f5154 100644
--- a/src/Lucene.Net.Core/Util/Mutable/MutableValue.cs
+++ b/src/Lucene.Net.Core/Util/Mutable/MutableValue.cs
@@ -1,3 +1,4 @@
+using Lucene.Net.Support;
 using System;
 
 /*
@@ -24,7 +25,7 @@ namespace Lucene.Net.Util.Mutable
     ///
     /// @lucene.internal
     /// </summary>
-    public abstract class MutableValue : IComparable<MutableValue>
+    public abstract class MutableValue : IComparable<MutableValue>, IComparable
     {
         protected MutableValue()
         {
@@ -52,8 +53,27 @@ namespace Lucene.Net.Util.Mutable
                 int c = c1.GetHashCode() - c2.GetHashCode();
                 if (c == 0)
                 {
-                    //c = c1.CanonicalName.CompareTo(c2.CanonicalName);
-                    c = String.Compare(c1.Name, c2.Name, StringComparison.Ordinal);
+                    c = c1.FullName.CompareToOrdinal(c2.FullName);
+                }
+                return c;
+            }
+            return CompareSameType(other);
+        }
+
+
+        // LUCENENET specific implementation, for use with FunctionFirstPassGroupingCollector

+        // (note that IComparable<T> does not inherit IComparable, so we need to explicitly

+        // do that here in order to support IComparable)
+        public int CompareTo(object other)
+        {
+            Type c1 = this.GetType();
+            Type c2 = other.GetType();
+            if (c1 != c2)
+            {
+                int c = c1.GetHashCode() - c2.GetHashCode();
+                if (c == 0)
+                {
+                    c = c1.FullName.CompareToOrdinal(c2.FullName);
                 }
                 return c;
             }


Mime
View raw message