18 using System.Collections;
19 using Lucene.Net.Documents;
21 namespace SpellChecker.Net.Search.Spell
26 using Term = Lucene.Net.Index.Term;
34 internal System.String field;
42 virtual public System.Collections.Generic.IEnumerator<
string> GetWordsIterator()
44 return new LuceneIterator(
this);
47 public System.Collections.Generic.IEnumerator<
string> GetEnumerator()
49 return GetWordsIterator();
52 IEnumerator IEnumerable.GetEnumerator()
54 return GetEnumerator();
57 internal sealed
class LuceneIterator : System.Collections.Generic.IEnumerator<string>
60 private Term actualTerm;
61 private bool hasNextCalled;
63 private readonly LuceneDictionary enclosingInstance;
65 public LuceneIterator(LuceneDictionary enclosingInstance)
67 this.enclosingInstance = enclosingInstance;
70 termEnum = enclosingInstance.reader.Terms(
new Term(enclosingInstance.field,
""));
72 catch (System.IO.IOException ex)
74 System.Console.Error.WriteLine(ex.StackTrace);
86 hasNextCalled =
false;
87 return (actualTerm != null) ? actualTerm.Text : null;
92 object IEnumerator.Current
94 get {
return Current; }
97 public bool MoveNext()
101 actualTerm = termEnum.Term;
104 if (actualTerm == null)
return false;
106 System.String fieldt = actualTerm.Field;
110 if (fieldt != enclosingInstance.field)
128 public void Dispose()