19 using System.Collections.Generic;
20 using Lucene.Net.Util;
22 namespace Lucene.Net.Index
31 private sealed
class TermPositionsQueue :
PriorityQueue<TermPositions>
33 internal TermPositionsQueue(LinkedList<TermPositions> termPositions)
35 Initialize(termPositions.Count);
53 private sealed
class IntQueue
59 private void InitBlock()
61 _array =
new int[_arraySize];
63 private int _arraySize = 16;
64 private int _index = 0;
65 private int _lastIndex = 0;
68 internal void add(
int i)
70 if (_lastIndex == _arraySize)
73 _array[_lastIndex++] = i;
78 return _array[_index++];
83 System.Array.Sort(_array, _index, _lastIndex - _index);
94 return (_lastIndex - _index);
97 private void growArray()
99 int[] newArray =
new int[_arraySize * 2];
100 Array.Copy(_array, 0, newArray, 0, _arraySize);
108 private TermPositionsQueue _termPositionsQueue;
109 private IntQueue _posList;
111 private bool isDisposed;
119 var termPositions =
new System.Collections.Generic.LinkedList<
TermPositions>();
121 for (
int i = 0; i < terms.Length; i++)
124 _termPositionsQueue =
new TermPositionsQueue(termPositions);
125 _posList =
new IntQueue();
130 if (_termPositionsQueue.Size() == 0)
134 _doc = _termPositionsQueue.Peek().Doc;
139 tp = _termPositionsQueue.Peek();
141 for (
int i = 0; i < tp.
Freq; i++)
145 _termPositionsQueue.UpdateTop();
148 _termPositionsQueue.Pop();
152 while (_termPositionsQueue.Size() > 0 && _termPositionsQueue.Peek().Doc == _doc);
155 _freq = _posList.size();
160 public int NextPosition()
162 return _posList.next();
165 public bool SkipTo(
int target)
167 while (_termPositionsQueue.Peek() != null && target > _termPositionsQueue.Peek().Doc)
171 _termPositionsQueue.Add(tp);
185 get {
return _freq; }
188 [Obsolete(
"Use Dispose() instead")]
194 public void Dispose()
199 protected virtual void Dispose(
bool disposing)
201 if (isDisposed)
return;
205 while (_termPositionsQueue.Size() > 0)
206 _termPositionsQueue.Pop().Close();
214 public virtual void Seek(
Term arg0)
216 throw new System.NotSupportedException();
223 throw new System.NotSupportedException();
228 public virtual int Read(
int[] arg0,
int[] arg1)
230 throw new System.NotSupportedException();
236 public virtual int PayloadLength
238 get {
throw new System.NotSupportedException(); }
243 public virtual byte[] GetPayload(byte[] data,
int offset)
245 throw new System.NotSupportedException();
251 public virtual bool IsPayloadAvailable
253 get {
return false; }