23 using System.Collections.Generic;
26 using Lucene.Net.Analysis;
27 using Lucene.Net.Analysis.Tokenattributes;
29 namespace Lucene.Net.Index.Memory
31 public partial class MemoryIndex
33 private sealed
class KeywordTokenStream<T> :
TokenStream
35 private IEnumerator<T> iter;
36 private int start = 0;
40 public KeywordTokenStream(IEnumerable<T> keywords)
42 iter = keywords.GetEnumerator();
43 termAtt = AddAttribute<ITermAttribute>();
44 offsetAtt = AddAttribute<IOffsetAttribute>();
47 public override bool IncrementToken()
49 if (!iter.MoveNext())
return false;
53 throw new ArgumentException(
"keyword must not be null");
55 String term = obj.ToString();
57 termAtt.SetTermBuffer(term);
58 offsetAtt.SetOffset(start, start + termAtt.TermLength());
59 start += term.Length + 1;
63 protected override void Dispose(
bool disposing)