lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [1/3] git commit: BytesRefIterator
Date Sun, 07 Sep 2014 00:30:05 GMT
Repository: lucenenet
Updated Branches:
  refs/heads/master 49b3be5c0 -> 2d8a9639d


BytesRefIterator


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

Branch: refs/heads/master
Commit: adaf46e14a6e4603bcc42eac0e2312af5946f87c
Parents: 49b3be5
Author: Itamar Syn-Hershko <itamar@code972.com>
Authored: Sun Sep 7 02:42:06 2014 +0300
Committer: Itamar Syn-Hershko <itamar@code972.com>
Committed: Sun Sep 7 02:42:06 2014 +0300

----------------------------------------------------------------------
 src/Lucene.Net.Core/Index/TermsEnum.cs          |   4 +-
 src/Lucene.Net.Core/Util/BytesRef.cs            |   2 +-
 src/Lucene.Net.Core/Util/BytesRefArray.cs       |   6 +-
 src/Lucene.Net.Core/Util/BytesRefIterator.cs    | 133 +++----------------
 .../core/Util/TestBytesRefArray.cs              |   4 +-
 5 files changed, 26 insertions(+), 123 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/adaf46e1/src/Lucene.Net.Core/Index/TermsEnum.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/TermsEnum.cs b/src/Lucene.Net.Core/Index/TermsEnum.cs
index 03c20c2..3bf8f9b 100644
--- a/src/Lucene.Net.Core/Index/TermsEnum.cs
+++ b/src/Lucene.Net.Core/Index/TermsEnum.cs
@@ -1,4 +1,5 @@
 using System.Collections.Generic;
+using Lucene.Net.Util;
 
 namespace Lucene.Net.Index
 {
@@ -24,7 +25,6 @@ namespace Lucene.Net.Index
     using AttributeSource = Lucene.Net.Util.AttributeSource;
     using Bits = Lucene.Net.Util.Bits;
     using BytesRef = Lucene.Net.Util.BytesRef;
-    using IBytesRefIterator = Lucene.Net.Util.IBytesRefIterator;
 
     /// <summary>
     /// Iterator to seek (<seealso cref="#seekCeil(BytesRef)"/>, {@link
@@ -44,7 +44,7 @@ namespace Lucene.Net.Index
     ///
     /// @lucene.experimental
     /// </summary>
-    public abstract class TermsEnum : IBytesRefIterator
+    public abstract class TermsEnum : BytesRefIterator
     {
         public abstract IComparer<BytesRef> Comparator { get; }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/adaf46e1/src/Lucene.Net.Core/Util/BytesRef.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/BytesRef.cs b/src/Lucene.Net.Core/Util/BytesRef.cs
index a370e3f..5a28e94 100644
--- a/src/Lucene.Net.Core/Util/BytesRef.cs
+++ b/src/Lucene.Net.Core/Util/BytesRef.cs
@@ -298,7 +298,7 @@ namespace Lucene.Net.Util
             }
         }
 
-        private class UTF8SortedAsUnicodeComparator : IComparer<BytesRef>
+        internal class UTF8SortedAsUnicodeComparator : IComparer<BytesRef>
         {
             // Only singleton
             internal UTF8SortedAsUnicodeComparator()

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/adaf46e1/src/Lucene.Net.Core/Util/BytesRefArray.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/BytesRefArray.cs b/src/Lucene.Net.Core/Util/BytesRefArray.cs
index 7d716d4..2a5eca1 100644
--- a/src/Lucene.Net.Core/Util/BytesRefArray.cs
+++ b/src/Lucene.Net.Core/Util/BytesRefArray.cs
@@ -171,7 +171,7 @@ namespace Lucene.Net.Util
         /// <summary>
         /// sugar for <seealso cref="#iterator(Comparator)"/> with a <code>null</code>
comparator
         /// </summary>
-        public IBytesRefIterator Iterator()
+        public BytesRefIterator Iterator()
         {
             return Iterator(null);
         }
@@ -190,7 +190,7 @@ namespace Lucene.Net.Util
         /// this is a non-destructive operation.
         /// </p>
         /// </summary>
-        public IBytesRefIterator Iterator(IComparer<BytesRef> comp)
+        public BytesRefIterator Iterator(IComparer<BytesRef> comp)
         {
             BytesRef spare = new BytesRef();
             int size = Size();
@@ -198,7 +198,7 @@ namespace Lucene.Net.Util
             return new BytesRefIteratorAnonymousInnerClassHelper(this, comp, spare, size,
indices);
         }
 
-        private class BytesRefIteratorAnonymousInnerClassHelper : IBytesRefIterator
+        private class BytesRefIteratorAnonymousInnerClassHelper : BytesRefIterator
         {
             private readonly BytesRefArray OuterInstance;
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/adaf46e1/src/Lucene.Net.Core/Util/BytesRefIterator.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/BytesRefIterator.cs b/src/Lucene.Net.Core/Util/BytesRefIterator.cs
index d952524..aa72b6f 100644
--- a/src/Lucene.Net.Core/Util/BytesRefIterator.cs
+++ b/src/Lucene.Net.Core/Util/BytesRefIterator.cs
@@ -1,4 +1,5 @@
 using System.Collections.Generic;
+using System.IO;
 
 namespace Lucene.Net.Util
 {
@@ -19,37 +20,10 @@ namespace Lucene.Net.Util
      * limitations under the License.
      */
 
-    // LUCENE TO-DO rewrote entire class
-
-    public interface IBytesRefIterator
-    {
-        BytesRef Next();
-
-        IComparer<BytesRef> Comparator { get; }
-    }
-
-    // .NET Port: in Java, you can have static fields and anonymous classes inside interfaces.
-    // Here, we're naming a static class similarly to the Java interface to mimic this behavior.
-    public static class BytesRefIterator
-    {
-        public static readonly IBytesRefIterator EMPTY = new EmptyBytesRefIterator();
-
-        private class EmptyBytesRefIterator : IBytesRefIterator
-        {
-            public BytesRef Next()
-            {
-                return null;
-            }
-
-            public IComparer<BytesRef> Comparator
-            {
-                get { return null; }
-            }
-        }
-    }
-
-    /*
-    public class BytesRefIterator
+    /// <summary>
+    /// A simple iterator interface for <seealso cref="BytesRef"/> iteration.
+    /// </summary>
+    public interface BytesRefIterator
     {
         /// <summary>
         /// Increments the iteration to the next <seealso cref="BytesRef"/> in the
iterator.
@@ -61,100 +35,29 @@ namespace Lucene.Net.Util
         /// <returns> the next <seealso cref="BytesRef"/> in the iterator or
<code>null</code> if
         ///         the end of the iterator is reached. </returns>
         /// <exception cref="IOException"> If there is a low-level I/O error. </exception>
-        public abstract BytesRef Next();
+        BytesRef Next();
 
         /// <summary>
-	    /// Return the <seealso cref="BytesRef"/> Comparator used to sort terms provided
by the
-	    /// iterator. this may return null if there are no items or the iterator is not
-	    /// sorted. Callers may invoke this method many times, so it's best to cache a
-	    /// single instance & reuse it.
-	    /// </summary>
-        public abstract IComparer<BytesRef> Comparator { get; }
-
-        public static BytesRefIteratorHelper EMPTY = BytesRefIteratorHelper.CreateBytesRefIteratorHelper();
+        /// Return the <seealso cref="BytesRef"/> Comparator used to sort terms provided
by the
+        /// iterator. this may return null if there are no items or the iterator is not
+        /// sorted. Callers may invoke this method many times, so it's best to cache a
+        /// single instance & reuse it.
+        /// </summary>
+        IComparer<BytesRef> Comparator { get; }
     }
 
-    /// <summary>
-    /// Singleton BytesRefIterator that iterates over 0 BytesRefs. </summary>
-    public class BytesRefIteratorHelper : BytesRefIterator
+    public class EmptyBytesRefIterator : BytesRefIterator
     {
-        private BytesRefIteratorHelper()
-        {
-            me = null;
-        }
-        private static BytesRefIteratorHelper me;
-        public static BytesRefIteratorHelper CreateBytesRefIteratorHelper()
-        {
-            if (BytesRefIteratorHelper.me == null)
-                return new BytesRefIteratorHelper();
-            return me;
-        }
+        public static readonly BytesRefIterator Instance = new EmptyBytesRefIterator();
 
-        public override BytesRef Next()
+        public BytesRef Next()
         {
             return null;
         }
 
-        public override IComparer<BytesRef> Comparator
+        public IComparer<BytesRef> Comparator
         {
-            get;
+            get { return null; }
         }
-    }*/
-
-    /*
-
-	/// <summary>
-	/// A simple iterator interface for <seealso cref="BytesRef"/> iteration.
-	/// </summary>
-	public interface BytesRefIterator
-	{
-	  /// <summary>
-	  /// Increments the iteration to the next <seealso cref="BytesRef"/> in the iterator.
-	  /// Returns the resulting <seealso cref="BytesRef"/> or <code>null</code>
if the end of
-	  /// the iterator is reached. The returned BytesRef may be re-used across calls
-	  /// to next. After this method returns null, do not call it again: the results
-	  /// are undefined.
-	  /// </summary>
-	  /// <returns> the next <seealso cref="BytesRef"/> in the iterator or <code>null</code>
if
-	  ///         the end of the iterator is reached. </returns>
-	  /// <exception cref="IOException"> If there is a low-level I/O error. </exception>
-	  BytesRef Next();
-
-	  /// <summary>
-	  /// Return the <seealso cref="BytesRef"/> Comparator used to sort terms provided
by the
-	  /// iterator. this may return null if there are no items or the iterator is not
-	  /// sorted. Callers may invoke this method many times, so it's best to cache a
-	  /// single instance & reuse it.
-	  /// </summary>
-	  IComparer<BytesRef> Comparator {get;}
-
-	  /// <summary>
-	  /// Singleton BytesRefIterator that iterates over 0 BytesRefs. </summary>
-//	  public static final BytesRefIterator EMPTY = new BytesRefIteratorAnonymousInnerClassHelper();
-	}
-
-	public static class BytesRefIterator_Fields
-	{
-		  //public static readonly return Null;
-
-		  private class BytesRefIteratorAnonymousInnerClassHelper : BytesRefIterator
-		  {
-			  public BytesRefIteratorAnonymousInnerClassHelper()
-			  {
-			  }
-
-			  public override BytesRef Next()
-			  {
-			  }
-
-			  public override IComparer<BytesRef> Comparator
-			  {
-				  get
-				  {
-				  }
-			  }
-		  }
-		  //public static readonly return Null;
-	}
-    */
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/adaf46e1/src/Lucene.Net.Tests/core/Util/TestBytesRefArray.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Util/TestBytesRefArray.cs b/src/Lucene.Net.Tests/core/Util/TestBytesRefArray.cs
index 0cd9698..92c1db1 100644
--- a/src/Lucene.Net.Tests/core/Util/TestBytesRefArray.cs
+++ b/src/Lucene.Net.Tests/core/Util/TestBytesRefArray.cs
@@ -63,7 +63,7 @@ namespace Lucene.Net.Util
                 }
                 for (int i = 0; i < 2; i++)
                 {
-                    IBytesRefIterator iterator = list.Iterator();
+                    BytesRefIterator iterator = list.Iterator();
                     foreach (string @string in stringList)
                     {
                         Assert.AreEqual(@string, iterator.Next().Utf8ToString());
@@ -98,7 +98,7 @@ namespace Lucene.Net.Util
                 }
 
                 stringList.Sort();
-                IBytesRefIterator iter = list.Iterator(BytesRef.UTF8SortedAsUTF16Comparer);
+                BytesRefIterator iter = list.Iterator(BytesRef.UTF8SortedAsUTF16Comparer);
                 int a = 0;
                 while ((spare = iter.Next()) != null)
                 {


Mime
View raw message