19 using Lucene.Net.Util;
21 namespace Lucene.Net.Search
35 protected internal static readonly
TopDocs EMPTY_TOPDOCS =
new TopDocs(0,
new ScoreDoc[0], System.Single.NaN);
45 protected internal int internalTotalHits;
55 protected internal virtual void PopulateResults(
ScoreDoc[] results,
int howMany)
57 for (
int i = howMany - 1; i >= 0; i--)
59 results[i] = pq.
Pop();
70 return results == null?EMPTY_TOPDOCS:
new TopDocs(internalTotalHits, results);
74 public virtual int TotalHits
76 get {
return internalTotalHits; }
85 return TopDocs(0, internalTotalHits < pq.
Size()?internalTotalHits:pq.
Size());
104 return TopDocs(start, internalTotalHits < pq.
Size()?internalTotalHits:pq.
Size());
126 int size = internalTotalHits < pq.
Size()?internalTotalHits:pq.
Size();
130 if (start < 0 || start >= size || howMany <= 0)
132 return NewTopDocs(null, start);
136 howMany = System.Math.Min(size - start, howMany);
144 for (
int i = pq.
Size() - start - howMany; i > 0; i--)
150 PopulateResults(results, howMany);
152 return NewTopDocs(results, start);