xapian-core  2.0.0
inmemory_positionlist.h
Go to the documentation of this file.
1 
4 /* Copyright 2017 Olly Betts
5  *
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.
10  *
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.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see
18  * <https://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef XAPIAN_INCLUDED_INMEMORY_POSITIONLIST_H
22 #define XAPIAN_INCLUDED_INMEMORY_POSITIONLIST_H
23 
24 #include "api/smallvector.h"
25 #include "backends/positionlist.h"
26 
31 
36  size_t index = size_t(-1);
37 
39  void operator=(const InMemoryPositionList&) = delete;
40 
43 
44  public:
51 
53  explicit
55  : positions(std::move(positions_)) {}
56 
58  explicit
60  : positions(positions_.copy()) {}
61 
64  positions = std::move(positions_);
65  index = size_t(-1);
66  }
67 
69  void assign(const Xapian::VecCOW<Xapian::termpos>& positions_) {
70  positions = positions_.copy();
71  index = size_t(-1);
72  }
73 
75 
76  Xapian::termpos back() const;
77 
79 
80  bool next();
81 
83 };
84 
85 #endif // XAPIAN_INCLUDED_INMEMORY_POSITIONLIST_H
PositionList from an InMemory DB or a Document object.
Xapian::termpos back() const
Return the final entry in this positionlist.
void assign(const Xapian::VecCOW< Xapian::termpos > &positions_)
Assign copied positional data.
Xapian::VecCOW< Xapian::termpos > positions
Sorted list of term positions.
void operator=(const InMemoryPositionList &)=delete
Don't allow assignment.
bool skip_to(Xapian::termpos termpos)
Skip forward to the specified position.
Xapian::termpos get_position() const
Return the current position.
Xapian::termcount get_approx_size() const
Return approximate size of this positionlist.
InMemoryPositionList(const Xapian::VecCOW< Xapian::termpos > &positions_)
Construct with copied positional data.
InMemoryPositionList()
Construct with an empty position list.
size_t index
Current index into positions.
InMemoryPositionList(const InMemoryPositionList &)=delete
Don't allow copying.
InMemoryPositionList(Xapian::VecCOW< Xapian::termpos > &&positions_)
Move construct with positional data.
bool next()
Advance to the next entry in the positionlist.
void assign(Xapian::VecCOW< Xapian::termpos > &&positions_)
Move assign positional data.
Abstract base class for iterating term positions in a document.
Definition: positionlist.h:32
Suitable for "simple" type T.
Definition: smallvector.h:62
auto copy() const -> typename std::enable_if_t< ENABLE, Vec_to_copy >
Definition: smallvector.h:112
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Definition: types.h:64
unsigned XAPIAN_TERMPOS_BASE_TYPE termpos
A term position within a document or query.
Definition: types.h:75
Abstract base class for iterating term positions in a document.
Custom vector implementations using small vector optimisation.