[ci] Try to get .gitignore check to work
[xapian.git] / xapian-core / matcher / orpositionlist.h
blobb25a5251c063ce2050a348ecdbeeefb348759987
1 /** @file orpositionlist.h
2 * @brief Merge two PositionList objects using an OR operation.
3 */
4 /* Copyright (C) 2007,2010,2017 Olly Betts
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef XAPIAN_INCLUDED_ORPOSITIONLIST_H
22 #define XAPIAN_INCLUDED_ORPOSITIONLIST_H
24 #include "backends/positionlist.h"
25 #include "api/postlist.h"
27 #include "xapian/error.h"
28 #include <algorithm>
29 #include <vector>
31 class OrPositionList : public PositionList {
32 /// The PositionList sub-objects.
33 std::vector<PositionList*> pls;
35 /** Current positions of the subobjects.
37 * This will be empty when this position list hasn't yet started.
39 std::vector<Xapian::termpos> current;
41 /// Current position of this object.
42 Xapian::termpos current_pos;
44 public:
45 OrPositionList() { }
47 PositionList* gather(PostList* pl) {
48 pls.clear();
49 current.clear();
50 pl->gather_position_lists(this);
51 if (pls.size() == 1)
52 return pls[0];
53 return this;
56 void add_poslist(PositionList* poslist) {
57 pls.push_back(poslist);
60 Xapian::termcount get_approx_size() const;
62 Xapian::termpos get_position() const;
64 bool next();
66 bool skip_to(Xapian::termpos termpos);
69 #endif // XAPIAN_INCLUDED_ORPOSITIONLIST_H