blob: 0bd196a7ffa6078f2b2d452cf7c085fd0ce56811 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/*------------------------------------------------------------------------------
* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
*
* Distributable under the terms of either the Apache License (Version 2.0) or
* the GNU Lesser General Public License, as specified in the COPYING file.
------------------------------------------------------------------------------*/
#ifndef _lucene_search_HitQueue_
#define _lucene_search_HitQueue_
#if defined(_LUCENE_PRAGMA_ONCE)
# pragma once
#endif
#include "SearchHeader.h"
CL_NS_DEF(search)
/**
* An optimised PriorityQueue which takes ScoreDoc structs. Some by-ref passing
* and memory related optimisations have been done.
*/
class HitQueue: LUCENE_BASE {
private:
ScoreDoc* heap;
size_t _size;
size_t maxSize;
void upHeap();
void downHeap();
protected:
bool lessThan(struct ScoreDoc& hitA, struct ScoreDoc& hitB);
public:
void adjustTop();
struct ScoreDoc& top();
void put(struct ScoreDoc& element);
ScoreDoc pop();
/**
* Adds element to the PriorityQueue in log(size) time if either
* the PriorityQueue is not full, or not lessThan(element, top()).
* @param element
* @return true if element is added, false otherwise.
*/
bool insert(struct ScoreDoc& element);
/**
* Returns the number of elements currently stored in the PriorityQueue.
*/
size_t size();
HitQueue(const int32_t maxSize);
~HitQueue();
};
CL_NS_END
#endif
|