xapian-core  1.4.25
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
Xapian::MSetIterator Class Reference

Iterator over a Xapian::MSet. More...

#include <mset.h>

+ Collaboration diagram for Xapian::MSetIterator:

Public Member Functions

 MSetIterator ()
 Create an unpositioned MSetIterator. More...
 
Xapian::docid operator* () const
 Get the numeric document id for the current position. More...
 
MSetIteratoroperator++ ()
 Advance the iterator to the next position. More...
 
MSetIterator operator++ (int)
 Advance the iterator to the next position (postfix version). More...
 
MSetIteratoroperator-- ()
 Move the iterator to the previous position. More...
 
MSetIterator operator-- (int)
 Move the iterator to the previous position (postfix version). More...
 
MSetIteratoroperator+= (difference_type n)
 Move the iterator forwards by n positions. More...
 
MSetIteratoroperator-= (difference_type n)
 Move the iterator back by n positions. More...
 
MSetIterator operator+ (difference_type n) const
 Return the iterator incremented by n positions. More...
 
MSetIterator operator- (difference_type n) const
 Return the iterator decremented by n positions. More...
 
difference_type operator- (const MSetIterator &o) const
 Return the number of positions between o and this iterator. More...
 
Xapian::doccount get_rank () const
 Return the MSet rank for the current position. More...
 
Xapian::Document get_document () const
 Get the Document object for the current position. More...
 
double get_weight () const
 Get the weight for the current position. More...
 
std::string get_collapse_key () const
 Return the collapse key for the current position. More...
 
Xapian::doccount get_collapse_count () const
 Return a count of the number of collapses done onto the current key. More...
 
std::string get_sort_key () const
 Return the sort key for the current position. More...
 
int get_percent () const
 Convert the weight of the current iterator position to a percentage. More...
 
std::string get_description () const
 Return a string describing this object. More...
 

Private Types

typedef std::random_access_iterator_tag iterator_category
 
typedef std::string value_type
 
typedef Xapian::termcount_diff difference_type
 
typedef std::string * pointer
 
typedef std::string & reference
 

Private Member Functions

 MSetIterator (const Xapian::MSet &mset_, Xapian::doccount off_from_end_)
 

Private Attributes

Xapian::MSet mset
 
Xapian::MSet::size_type off_from_end
 

Friends

class MSet
 

Detailed Description

Iterator over a Xapian::MSet.

Definition at line 368 of file mset.h.

Member Typedef Documentation

◆ difference_type

MSetIterator is what the C++ STL calls an random_access_iterator.

The following typedefs allow std::iterator_traits<> to work so that this iterator can be used with the STL.

These are deliberately hidden from the Doxygen-generated docs, as the machinery here isn't interesting to API users. They just need to know that Xapian iterator classes are compatible with the STL.

Definition at line 433 of file mset.h.

◆ iterator_category

typedef std::random_access_iterator_tag Xapian::MSetIterator::iterator_category
private

MSetIterator is what the C++ STL calls an random_access_iterator.

The following typedefs allow std::iterator_traits<> to work so that this iterator can be used with the STL.

These are deliberately hidden from the Doxygen-generated docs, as the machinery here isn't interesting to API users. They just need to know that Xapian iterator classes are compatible with the STL.

Definition at line 429 of file mset.h.

◆ pointer

typedef std::string* Xapian::MSetIterator::pointer
private

MSetIterator is what the C++ STL calls an random_access_iterator.

The following typedefs allow std::iterator_traits<> to work so that this iterator can be used with the STL.

These are deliberately hidden from the Doxygen-generated docs, as the machinery here isn't interesting to API users. They just need to know that Xapian iterator classes are compatible with the STL.

Definition at line 435 of file mset.h.

◆ reference

typedef std::string& Xapian::MSetIterator::reference
private

MSetIterator is what the C++ STL calls an random_access_iterator.

The following typedefs allow std::iterator_traits<> to work so that this iterator can be used with the STL.

These are deliberately hidden from the Doxygen-generated docs, as the machinery here isn't interesting to API users. They just need to know that Xapian iterator classes are compatible with the STL.

Definition at line 437 of file mset.h.

◆ value_type

typedef std::string Xapian::MSetIterator::value_type
private

MSetIterator is what the C++ STL calls an random_access_iterator.

The following typedefs allow std::iterator_traits<> to work so that this iterator can be used with the STL.

These are deliberately hidden from the Doxygen-generated docs, as the machinery here isn't interesting to API users. They just need to know that Xapian iterator classes are compatible with the STL.

Definition at line 431 of file mset.h.

Constructor & Destructor Documentation

◆ MSetIterator() [1/2]

Xapian::MSetIterator::MSetIterator ( const Xapian::MSet mset_,
Xapian::doccount  off_from_end_ 
)
inlineprivate

Definition at line 371 of file mset.h.

◆ MSetIterator() [2/2]

Xapian::MSetIterator::MSetIterator ( )
inline

Create an unpositioned MSetIterator.

Definition at line 386 of file mset.h.

References Xapian::operator*().

Member Function Documentation

◆ get_collapse_count()

Xapian::doccount Xapian::MSetIterator::get_collapse_count ( ) const

Return a count of the number of collapses done onto the current key.

This starts at 0, and is incremented each time an item is eliminated because its key is the same as that of the current item (as returned by get_collapse_key()).

Note that this is NOT necessarily one less than the total number of matching documents with this collapse key due to various optimisations implemented in the matcher - for example, it can skip documents completely if it can prove their weight wouldn't be enough to make the result set.

You can say is that if get_collapse_count() > 0 then there are >= get_collapse_count() other documents with the current collapse key. But if get_collapse_count() == 0 then there may or may not be other such documents.

Definition at line 480 of file omenquire.cc.

References Assert, AssertRel, and Xapian::MSet::size().

◆ get_collapse_key()

std::string Xapian::MSetIterator::get_collapse_key ( ) const

Return the collapse key for the current position.

If collapsing isn't in use, an empty string will be returned.

Definition at line 470 of file omenquire.cc.

References Assert, AssertRel, and Xapian::MSet::size().

◆ get_description()

string Xapian::MSetIterator::get_description ( ) const

Return a string describing this object.

Definition at line 500 of file omenquire.cc.

References Xapian::Internal::str().

◆ get_document()

Document Xapian::MSetIterator::get_document ( ) const

Get the Document object for the current position.

Definition at line 450 of file omenquire.cc.

References Assert, AssertRel, and Xapian::MSet::size().

Referenced by DEFINE_TESTCASE().

◆ get_percent()

int Xapian::MSetIterator::get_percent ( ) const
inline

Convert the weight of the current iterator position to a percentage.

The matching document with the highest weight will get 100% if it matches all the weighted query terms, and proportionally less if it only matches some, and other weights are scaled by the same factor.

Documents with a non-zero score will always score at least 1%.

Note that these generally aren't percentages of anything meaningful (unless you use a custom weighting formula where they are!)

Definition at line 531 of file mset.h.

References Xapian::MSet::convert_to_percent().

Referenced by DEFINE_TESTCASE().

◆ get_rank()

Xapian::doccount Xapian::MSetIterator::get_rank ( ) const
inline

Return the MSet rank for the current position.

The rank of mset[0] is mset.get_firstitem().

Definition at line 477 of file mset.h.

References Xapian::MSet::get_firstitem(), and Xapian::MSet::size().

◆ get_sort_key()

string Xapian::MSetIterator::get_sort_key ( ) const

Return the sort key for the current position.

If sorting didn't use a key then an empty string will be returned.

Since
Added in Xapian 1.4.6.

Definition at line 490 of file omenquire.cc.

References Assert, AssertRel, and Xapian::MSet::size().

◆ get_weight()

double Xapian::MSetIterator::get_weight ( ) const

Get the weight for the current position.

Definition at line 460 of file omenquire.cc.

References Assert, AssertRel, and Xapian::MSet::size().

Referenced by Xapian::MSet::convert_to_percent(), DEFINE_TESTCASE(), mset_range_is_same(), mset_range_is_same_weights(), and print_mset_weights().

◆ operator*()

Xapian::docid Xapian::MSetIterator::operator* ( ) const

Get the numeric document id for the current position.

Definition at line 440 of file omenquire.cc.

References Assert, AssertRel, and Xapian::MSet::size().

◆ operator+()

MSetIterator Xapian::MSetIterator::operator+ ( difference_type  n) const
inline

Return the iterator incremented by n positions.

If n is negative, decrements by (-n) positions.

Definition at line 456 of file mset.h.

◆ operator++() [1/2]

MSetIterator& Xapian::MSetIterator::operator++ ( )
inline

Advance the iterator to the next position.

Definition at line 392 of file mset.h.

◆ operator++() [2/2]

MSetIterator Xapian::MSetIterator::operator++ ( int  )
inline

Advance the iterator to the next position (postfix version).

Definition at line 398 of file mset.h.

◆ operator+=()

MSetIterator& Xapian::MSetIterator::operator+= ( difference_type  n)
inline

Move the iterator forwards by n positions.

Definition at line 441 of file mset.h.

◆ operator-() [1/2]

MSetIterator Xapian::MSetIterator::operator- ( difference_type  n) const
inline

Return the iterator decremented by n positions.

If n is negative, increments by (-n) positions.

Definition at line 464 of file mset.h.

◆ operator-() [2/2]

difference_type Xapian::MSetIterator::operator- ( const MSetIterator o) const
inline

Return the number of positions between o and this iterator.

Definition at line 469 of file mset.h.

References off_from_end.

◆ operator--() [1/2]

MSetIterator& Xapian::MSetIterator::operator-- ( )
inline

Move the iterator to the previous position.

Definition at line 405 of file mset.h.

◆ operator--() [2/2]

MSetIterator Xapian::MSetIterator::operator-- ( int  )
inline

Move the iterator to the previous position (postfix version).

Definition at line 411 of file mset.h.

◆ operator-=()

MSetIterator& Xapian::MSetIterator::operator-= ( difference_type  n)
inline

Move the iterator back by n positions.

Definition at line 447 of file mset.h.

Friends And Related Function Documentation

◆ MSet

friend class MSet
friend

Definition at line 369 of file mset.h.

Member Data Documentation

◆ mset

Xapian::MSet Xapian::MSetIterator::mset
private

The MSet we are iterating over.

Definition at line 376 of file mset.h.

Referenced by Xapian::iterator_rewind(), and Xapian::iterator_rewound().

◆ off_from_end

Xapian::MSet::size_type Xapian::MSetIterator::off_from_end
private

The current position of the iterator.

We store the offset from the end of mset, since that means MSet::end() just needs to set this member to 0.

Definition at line 383 of file mset.h.

Referenced by Xapian::MSet::fetch(), Xapian::iterator_rewind(), Xapian::iterator_rewound(), Xapian::iterator_valid(), operator-(), Xapian::operator<(), and Xapian::operator==().


The documentation for this class was generated from the following files: