[ci] Fix clang-santisers job for GHA change
[xapian.git] / xapian-core / expand / esetinternal.h
blob2171f71bc74e851d8c1d365cb7cebb50ec298449
1 /** @file
2 * @brief Xapian::ESet::Internal class
3 */
4 /* Copyright (C) 2008,2010,2011 Olly Betts
5 * Copyright (C) 2011 Action Without Borders
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #ifndef XAPIAN_INCLUDED_ESETINTERNAL_H
23 #define XAPIAN_INCLUDED_ESETINTERNAL_H
25 #include "xapian/intrusive_ptr.h"
26 #include "xapian/enquire.h"
27 #include "xapian/eset.h"
28 #include "xapian/types.h"
30 #include <algorithm>
31 #include <string>
32 #include <vector>
34 namespace Xapian {
35 class Database;
36 class ExpandDecider;
38 namespace Internal {
39 class ExpandWeight;
41 /// Class combining a term and its expand weight.
42 class ExpandTerm {
43 friend class Xapian::ESet::Internal;
45 /// The expand weight calculated for this term.
46 double wt;
48 /// The term.
49 std::string term;
51 public:
52 /// Constructor.
53 ExpandTerm(double wt_, const std::string & term_)
54 : wt(wt_), term(term_) { }
56 /// Implement custom swap for ESet sorting efficiency.
57 void swap(ExpandTerm & o) {
58 std::swap(wt, o.wt);
59 std::swap(term, o.term);
62 /// Ordering relation for ESet contents.
63 bool operator<(const ExpandTerm & o) const {
64 if (wt > o.wt) return true;
65 if (wt < o.wt) return false;
66 return term > o.term;
69 std::string get_term() const { return term; }
71 double get_weight() const { return wt; }
73 /// Return a string describing this object.
74 std::string get_description() const;
79 /// Class which actually implements Xapian::ESet.
80 class ESet::Internal : public Xapian::Internal::intrusive_base {
81 friend class ESet;
82 friend class ESetIterator;
84 /** This is a lower bound on the ESet size if an infinite number of results
85 * were requested.
87 * It will of course always be true that: ebound >= items.size()
89 Xapian::termcount ebound = 0;
91 /// The ExpandTerm objects which represent the items in the ESet.
92 std::vector<Xapian::Internal::ExpandTerm> items;
94 /// Don't allow assignment.
95 void operator=(const Internal &);
97 /// Don't allow copying.
98 Internal(const Internal &);
100 public:
101 /// Construct an empty ESet::Internal.
102 Internal() { }
104 /// Run the "expand" operation which fills the ESet.
105 void expand(Xapian::termcount max_esize,
106 const Xapian::Database & db,
107 const Xapian::RSet & rset,
108 const Xapian::ExpandDecider * edecider,
109 Xapian::Internal::ExpandWeight & eweight,
110 double min_wt);
112 /// Return a string describing this object.
113 std::string get_description() const;
118 #endif // XAPIAN_INCLUDED_ESETINTERNAL_H