xapian-core  1.4.25
inmemory_positionlist.cc
Go to the documentation of this file.
1 
4 /* Copyright 1999,2000,2001 BrightStation PLC
5  * Copyright 2003,2009 Olly Betts
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License as
9  * published by the Free Software Foundation; either version 2 of the
10  * License, or (at your option) any later version.
11  *
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.
16  *
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
20  * USA
21  */
22 
23 #include <config.h>
24 
25 #include "inmemory_positionlist.h"
26 
27 #include "debuglog.h"
28 #include "omassert.h"
29 
31  : positions(positions_), mypos(positions.begin()),
32  iterating_in_progress(false)
33 {
34 }
35 
36 void
38 {
39  positions = positions_;
40  mypos = positions.begin();
41  iterating_in_progress = false;
42 }
43 
46 {
47  return positions.size();
48 }
49 
52 {
54  Assert(mypos != positions.end());
55  return *mypos;
56 }
57 
58 bool
60 {
62  Assert(mypos != positions.end());
63  ++mypos;
64  } else {
65  iterating_in_progress = true;
66  }
67  return (mypos != positions.end());
68 }
69 
70 bool
72 {
74  while (mypos != positions.end() && *mypos < termpos) ++mypos;
75  return (mypos != positions.end());
76 }
PositionList from an InMemory DB or a Document object.
#define Assert(COND)
Definition: omassert.h:122
#define false
Definition: header.h:9
Xapian::termpos get_position() const
Gets current position.
bool next()
Move to the next item in the list.
vector< Xapian::termpos >::const_iterator mypos
Position of iteration through positions.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Definition: types.h:72
Xapian::termcount get_approx_size() const
Gets size of position list.
vector< Xapian::termpos > term_positions
Definition: documentterm.h:77
bool iterating_in_progress
True if we have started iterating.
vector< Xapian::termpos > positions
The list of positions.
InMemoryPositionList()
Default constructor.
unsigned XAPIAN_TERMPOS_BASE_TYPE termpos
A term position within a document or query.
Definition: types.h:83
Various assertion macros.
bool skip_to(Xapian::termpos termpos)
Move to the next item in the list.
Debug logging macros.
void set_data(const OmDocumentTerm::term_positions &positions_)
Fill list with data, and move the position to the start.