Details

    • Type: Sub-task Sub-task
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: Lucene.Net 2.9.4, Lucene.Net 2.9.4g, Lucene.Net 3.0.3
    • Fix Version/s: None
    • Labels:
      None
    • Environment:

      all

      Description

      The Iterator pattern in Java is equivalent to IEnumerable in .NET. Classes that were directly ported in Java using the Iterator pattern, cannot be used with Linq or foreach blocks in .NET.

      Next() would be equivalent to .NET's MoveNext(), and in the below case, Term() would be as .NET's Current property. In cases as below, it will require TermEnum to become an abstract class with Term and DocFreq properties, which would be returned from another class or method that implemented IEnumerable<TermEnum>.

       
      	public abstract class TermEnum : IDisposable
      	{
      		public abstract bool Next();
      		public abstract Term Term();
      		public abstract int DocFreq();
      		public abstract void  Close();
      	        public abstract void Dispose();
      	}
      

      would instead look something like:

       
      	public class TermFreq
      	{
      		public abstract Term { get; }
      		public abstract int { get; }
      	}
      
              public abstract class TermEnum : IEnumerable<TermFreq>, IDisposable
              {
                      // ...
              }
      

      Keep in mind that it is important that if the class being converted implements IDisposable, the class that is enumerating the terms (in this case TermEnum) should inherit from both IEnumerable<T> and IDisposable. This won't be any change to the user, as the compiler automatically calls IDisposable when used in a foreach loop.

        Activity

        Hide
        Christopher Currens added a comment -

        This requires too much of an API change to implement in 3.0.3. Unassigning from 3.0.3, and we can revisit it in a later release.

        Show
        Christopher Currens added a comment - This requires too much of an API change to implement in 3.0.3. Unassigning from 3.0.3, and we can revisit it in a later release.

          People

          • Assignee:
            Unassigned
            Reporter:
            Christopher Currens
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:

              Development