1 /** @file maptermlist.h
2 * @brief TermList which iterates a std::map.
4 /* Copyright 1999,2000,2001 BrightStation PLC
5 * Copyright 2002,2003,2004,2005,2006,2007,2008,2010,2011,2013 Olly Betts
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.
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
23 #ifndef OM_HGUARD_MAPTERMLIST_H
24 #define OM_HGUARD_MAPTERMLIST_H
28 #include "backends/inmemory/inmemory_positionlist.h"
29 #include "backends/document.h"
35 class MapTermList
: public TermList
{
37 Xapian::Document::Internal::document_terms::const_iterator it
;
38 Xapian::Document::Internal::document_terms::const_iterator it_end
;
42 MapTermList(const Xapian::Document::Internal::document_terms::const_iterator
&it_
,
43 const Xapian::Document::Internal::document_terms::const_iterator
&it_end_
)
44 : it(it_
), it_end(it_end_
), started(false)
47 // Gets size of termlist
48 Xapian::termcount
get_approx_size() const {
49 // This method shouldn't get called on a MapTermList.
54 // Gets current termname
55 string
get_termname() const {
61 // Get wdf of current term
62 Xapian::termcount
get_wdf() const {
65 return it
->second
.wdf
;
68 // Get num of docs indexed by term
69 Xapian::doccount
get_termfreq() const {
70 throw Xapian::InvalidOperationError("Can't get term frequency from a document termlist which is not associated with a database.");
73 const std::vector
<Xapian::termpos
> * get_vector_termpos() const {
74 return it
->second
.get_vector_termpos();
77 Xapian::PositionIterator
positionlist_begin() const {
78 auto p
= it
->second
.get_vector_termpos();
79 return Xapian::PositionIterator(new InMemoryPositionList(*p
));
82 Xapian::termcount
positionlist_count() const {
83 return it
->second
.positionlist_count();
93 while (it
!= it_end
&& it
->second
.is_deleted()) {
99 TermList
* skip_to(const std::string
& term
) {
100 while (it
!= it_end
&& it
->first
< term
) {
104 while (it
!= it_end
&& it
->second
.is_deleted()) {
110 // True if we're off the end of the list
111 bool at_end() const {
117 #endif /* OM_HGUARD_MAPTERMLIST_H */