NightOwl888 opened a new pull request #341:
URL: https://github.com/apache/lucenenet/pull/341


   Partially addresses #279.
   
   This PR migrates the following iterators to enumerators:
   
   1. All iterators in `Lucene.Net.Suggest`
   2. `FilterIterator<T>` and `MergedIterator<T>` were renamed 
`FilterEnumerator<T>` and `MergedEnumerator<T>`
   3. `TermsEnum` and all of its subclasses
   4. `TernaryTree.Iterator` in the `Lucene.Net.Analysis.Hyphenation` namespace 
was renamed `TernaryTree.Enumerator`
   5. `DirContentSource.Iterator` in the `Lucene.Net.Benchmarks.ByTask.Feeds` 
namespace was renamed `DirContentSource.Enumerator`
   6. `DirectDocValuesConsumer`'s iterators were also renamed to Enumerator
   
   It does not address:
   
   1. `DocIdBitSetIterator` and all subclasses
   2. `CharacterIterator`
   3. `BreakIterator` and all subclasses
   
   ## TermsEnum Syntax Change
   
   `TermsEnum` was made backward compatible with the old syntax, but is marked 
obsolete and will be removed before the final release of Lucene.NET 4.8.0. The 
new syntax is more familiar to .NET users.
   
   ```c#
   TermsEnum termEnum = terms.GetIterator(null);
   BytesRef term;
   while ((term = termEnum.Next()) != null)
   {
       // use term
   }
   ```
   
   becomes
   
   ```c#
   TermsEnum termEnum = terms.GetEnumerator();
   BytesRef term;
   while (termEnum.MoveNext())
   {
       term = termEnum.Term;
       // use term
   }
   ```
   
   It is also possible to use a foreach loop, which returns the `TermsEnum` 
after the advance in each loop.
   
   ```c#
   BytesRef term;
   foreach (TermsEnum termsEnum in terms)
   {
       term = termsEnum.Term;
       // use term
   
       // or use other properties of TermsEnum
       var freq = termsEnum.TotalTermFreq;
   }
   ```
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to