Qx v0.6
Qt Extensions Library
Loading...
Searching...
No Matches
Qx::Bimap< Left, Right >::const_iterator Class Reference

The Bimap::const_iterator class provides an STL-style const iterator for Bimap. More...

#include <qx/core/qx-bimap.h>

Public Member Functions

 const_iterator ()
 
const Left & left () const
 
std::pair< const Left &, const Right & > operator* () const
 
const_iteratoroperator++ ()
 
const_iterator operator++ (int)
 
bool operator== (const const_iterator &other) const =default
 
const Right & right () const
 

Friends

class Bimap< Left, Right >
 

Detailed Description

template<typename Left, typename Right>
class Qx::Bimap< Left, Right >::const_iterator

Bimap<Left, Right>::const_iterator allows you to iterate over a Bimap.

The default Bimap::const_iterator constructor creates an uninitialized iterator. You must initialize it using a Bimap function like Bimap::cbegin(), Bimap::cend(), or Bimap::constFind() before you can start iterating.

Bimap stores its relationships in an arbitrary order.

Multiple iterators can be used on the same bimap. However, be aware that any modification performed directly on the Bimap (inserting and removing items) can cause the iterators to become invalid.

Inserting relationships into the bimap or calling methods such as Bimap::reserve() or Bimap::squeeze() can invalidate all iterators pointing into the bimap. Iterators are guaranteed to stay valid only as long as the Bimap doesn't have to grow/shrink its internal table. Using any iterator after a rehashing operation has occurred will lead to undefined behavior.

You can however safely use iterators to remove entries from the bimap using the Bimap::erase() method. This function can safely be called while iterating, and won't affect the order of items in the bimap.

Warning
Iterators on this container do not work exactly like STL-iterators. You should avoid copying a bimap while iterators are active on it. For more information, read Qt's "Implicit sharing iterator problem".

Constructor & Destructor Documentation

◆ const_iterator()

template<typename Left , typename Right >
Qx::Bimap< Left, Right >::const_iterator::const_iterator ( )
inline

Constructs an uninitialized iterator.

Functions like left(), right(), and operator++() must not be called on an uninitialized iterator. Use operator=() to assign a value to it before using it.

See also
Bimap::constBegin() and Bimap::constEnd().

Member Function Documentation

◆ left()

template<typename Left , typename Right >
const Left & Qx::Bimap< Left, Right >::const_iterator::left ( ) const
inline

Returns the current relationship's Left value.

◆ operator*()

template<typename Left , typename Right >
std::pair< const Left &, const Right & > Qx::Bimap< Left, Right >::const_iterator::operator* ( ) const
inline

Returns the current relationship.

◆ operator++() [1/2]

template<typename Left , typename Right >
const_iterator Qx::Bimap< Left, Right >::const_iterator::operator++ ( )
inline

The prefix ++ operator (++i) advances the iterator to the next relationship in the bimap and returns an iterator to the new current relationship.

Calling this function on Bimap::constEnd() leads to undefined results.

◆ operator++() [2/2]

template<typename Left , typename Right >
const_iterator Qx::Bimap< Left, Right >::const_iterator::operator++ ( int )
inline

The postfix ++ operator (i++) advances the iterator to the next relationship in the bimap and returns an iterator to the previously current relationship.

Calling this function on Bimap::constEnd() leads to undefined results.

◆ operator==()

template<typename Left , typename Right >
bool Right & Qx::Bimap< Left, Right >::const_iterator::operator== ( const const_iterator & other) const
default

Returns true if other points to the same relationship as this iterator; otherwise, returns false.

◆ right()

template<typename Left , typename Right >
const Right & Qx::Bimap< Left, Right >::const_iterator::right ( ) const
inline

Returns the current relationship's Right value.


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