Tkrzw
Public Member Functions | Friends | List of all members
tkrzw::StdIndex< KEYTYPE, VALUETYPE, CMPTYPE >::Iterator Class Reference

Iterator for each record. More...

#include <tkrzw_index.h>

Public Member Functions

 ~Iterator ()
 Destructor. More...
 
 Iterator (const Iterator &rhs)=delete
 Copy and assignment are disabled. More...
 
Iteratoroperator= (const Iterator &rhs)=delete
 
void First ()
 Initializes the iterator to indicate the first record. More...
 
void Last ()
 Initializes the iterator to indicate the last record. More...
 
void Jump (const KEYTYPE &key, const VALUETYPE &value=VALUETYPE())
 Initializes the iterator to indicate a specific range. More...
 
void Next ()
 Moves the iterator to the next record. More...
 
void Previous ()
 Moves the iterator to the previous record. More...
 
bool Get (KEYTYPE *key=nullptr, VALUETYPE *value=nullptr)
 Gets the key and the value of the current record of the iterator. More...
 

Friends

class StdIndex< KEYTYPE, VALUETYPE, CMPTYPE >
 

Detailed Description

template<typename KEYTYPE, typename VALUETYPE, typename CMPTYPE = std::less<std::pair<KEYTYPE, VALUETYPE>>>
class tkrzw::StdIndex< KEYTYPE, VALUETYPE, CMPTYPE >::Iterator

Iterator for each record.

Constructor & Destructor Documentation

◆ ~Iterator()

template<typename KEYTYPE , typename VALUETYPE , typename CMPTYPE >
tkrzw::StdIndex< KEYTYPE, VALUETYPE, CMPTYPE >::Iterator::~Iterator

Destructor.

◆ Iterator()

template<typename KEYTYPE , typename VALUETYPE , typename CMPTYPE = std::less<std::pair<KEYTYPE, VALUETYPE>>>
tkrzw::StdIndex< KEYTYPE, VALUETYPE, CMPTYPE >::Iterator::Iterator ( const Iterator rhs)
explicitdelete

Copy and assignment are disabled.

Member Function Documentation

◆ First()

template<typename KEYTYPE , typename VALUETYPE , typename CMPTYPE >
void tkrzw::StdIndex< KEYTYPE, VALUETYPE, CMPTYPE >::Iterator::First

Initializes the iterator to indicate the first record.

◆ Last()

template<typename KEYTYPE , typename VALUETYPE , typename CMPTYPE >
void tkrzw::StdIndex< KEYTYPE, VALUETYPE, CMPTYPE >::Iterator::Last

Initializes the iterator to indicate the last record.

◆ Jump()

template<typename KEYTYPE , typename VALUETYPE , typename CMPTYPE >
void tkrzw::StdIndex< KEYTYPE, VALUETYPE, CMPTYPE >::Iterator::Jump ( const KEYTYPE &  key,
const VALUETYPE &  value = VALUETYPE() 
)

Initializes the iterator to indicate a specific range.

Parameters
keyThe key of the lower bound.
valueThe value of the lower bound.

If you set std::greater<std::pair<KEYTYPE, VALUETYPE>> as the comparator, values are also set in descending order. Then, in order to visit all record of the specified key, you should set the maximum value in the possible range.

◆ Next()

template<typename KEYTYPE , typename VALUETYPE , typename CMPTYPE >
void tkrzw::StdIndex< KEYTYPE, VALUETYPE, CMPTYPE >::Iterator::Next

Moves the iterator to the next record.

◆ Previous()

template<typename KEYTYPE , typename VALUETYPE , typename CMPTYPE >
void tkrzw::StdIndex< KEYTYPE, VALUETYPE, CMPTYPE >::Iterator::Previous

Moves the iterator to the previous record.

◆ Get()

template<typename KEYTYPE , typename VALUETYPE , typename CMPTYPE >
bool tkrzw::StdIndex< KEYTYPE, VALUETYPE, CMPTYPE >::Iterator::Get ( KEYTYPE *  key = nullptr,
VALUETYPE *  value = nullptr 
)

Gets the key and the value of the current record of the iterator.

Parameters
keyThe pointer to a string object to contain the record key. If it is nullptr, the key data is ignored.
valueThe pointer to a string object to contain the record value. If it is nullptr, the value data is ignored.
Returns
True on success or false on failure. If theres no record to fetch, false is returned.