gtkmm: Gtk::TreeIter< T > Class Template Reference

Typedefed as TreeModel::iterator and TreeModel::const_iterator. More...

#include <gtkmm/treeiter.h>

Inheritance diagram for Gtk::TreeIter< T >:

Public Types

using iterator_category = std::bidirectional_iterator_tag
 
using value_type = T
 
using difference_type = int
 
using reference = T&
 
using pointer = T*
 

Public Member Functions

 TreeIter ()
 
template<typename T2 , typename = typename std::enable_if< std::is_same<T, TreeConstRow>::value && std::is_same<T2, TreeRow>::value, T2>::type>
 TreeIter (const TreeIter< T2 >& src)
 iterator to const_iterator conversion. More...

 
template<typename T2 , typename = typename std::enable_if< std::is_same<T, TreeConstRow>::value && std::is_same<T2, TreeRow>::value, T2>::type>
TreeIteroperator= (const TreeIter< T2 >& src)
 iterator to const_iterator assignment. More...

 
TreeIteroperator++ ()
 
TreeIter operator++ (int)
 
TreeIteroperator-- ()
 Note that this is very slow compared to operator++(). More...

 
TreeIter operator-- (int)
 Note that this is very slow compared to operator++(int). More...

 
reference operator* () const
 
pointer operator-> () const
 
 operator bool () const
 Discover whether the iterator is valid, and not equal to end(). More...

 
- Public Member Functions inherited from Gtk::TreeIterBase3
bool equal (const TreeIterBase3& other) const
 
int get_stamp () const
 This is only useful when implementing a custom Gtk::TreeModel class. More...

 
void set_stamp (int stamp)
 This is only useful when implementing a custom Gtk::TreeModel class. More...

 
- Public Member Functions inherited from Gtk::TreeIterBase
 TreeIterBase (const TreeIterBase& other) noexcept
 
TreeIterBaseoperator= (const TreeIterBase& other) noexcept
 
 TreeIterBase (TreeIterBase&& other) noexcept
 
TreeIterBaseoperator= (TreeIterBase&& other) noexcept
 
 TreeIterBase ()
 
 TreeIterBase (const GtkTreeIter* gobject)
 
GtkTreeIter* gobj ()
 Provides access to the underlying C instance. More...

 
const GtkTreeIter* gobj () const
 Provides access to the underlying C instance. More...

 

Related Functions

(Note that these are not member functions.)

bool operator== (const TreeIterBase3& lhs, const TreeIterBase3& rhs)
 
bool operator!= (const TreeIterBase3& lhs, const TreeIterBase3& rhs)
 

Additional Inherited Members

- Static Public Member Functions inherited from Gtk::TreeIterBase
static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system. More...

 
- Protected Attributes inherited from Gtk::TreeIterBase
GtkTreeIter gobject_
 

Detailed Description

template<typename T>

class Gtk::TreeIter< T >

Typedefed as TreeModel::iterator and TreeModel::const_iterator.

A Gtk::TreeModel::iterator is a reference to a specific node on a specific model. It is a generic structure with an integer and three generic pointers. These are filled in by the model in a model-specific way.

One can convert a path to an iterator by calling Gtk::TreeModel::get_iter().

These iterators are the primary way of accessing a model and are similar to the iterators used by Gtk::TextBuffer. The model interface defines a set of operations using them for navigating the model.

The lifecycle of an iterator can be a little confusing at first. Iterators are expected to always be valid for as long as the model is unchanged (and doesn't emit a signal). Additionally, some models guarantee that an iterator is valid for as long as the node it refers to is valid (most notably the Gtk::TreeStore and Gtk::ListStore).

Although generally uninteresting, as one always has to allow for the case where iterators do not persist beyond a signal, some very important performance enhancements were made in the sort model. As a result, the Gtk::TreeModel::Flags::ITERS_PERSIST flag was added to indicate this behaviour - see Gtk::TreeModel::get_flags().

Template Parameters
TTreeRow for an iterator, TreeConstRow for a const_iterator.

Member Typedef Documentation

template <typename T >
using Gtk::TreeIter< T >::difference_type = int
template <typename T >
using Gtk::TreeIter< T >::iterator_category = std::bidirectional_iterator_tag
template <typename T >
using Gtk::TreeIter< T >::pointer = T*
template <typename T >
using Gtk::TreeIter< T >::reference = T&
template <typename T >
using Gtk::TreeIter< T >::value_type = T

Constructor & Destructor Documentation

template <typename T >
Gtk::TreeIter< T >::TreeIter ( )
template <typename T >
template <typename T2 , typename = typename std::enable_if< std::is_same<T, TreeConstRow>::value && std::is_same<T2, TreeRow>::value, T2>::type>
Gtk::TreeIter< T >::TreeIter ( const TreeIter< T2 >&  src)

iterator to const_iterator conversion.

Member Function Documentation

template <typename T >
Gtk::TreeIter< T >::operator bool ( ) const
inlineexplicit

Discover whether the iterator is valid, and not equal to end().

For instance,

if (treeiter)
do_something();
Since gtkmm 3.22:
template <typename T >
reference Gtk::TreeIter< T >::operator* ( ) const
inline
template <typename T >
TreeIter& Gtk::TreeIter< T >::operator++ ( )
template <typename T >
TreeIter Gtk::TreeIter< T >::operator++ ( int  )
template <typename T >
TreeIter& Gtk::TreeIter< T >::operator-- ( )

Note that this is very slow compared to operator++().

template <typename T >
TreeIter Gtk::TreeIter< T >::operator-- ( int  )

Note that this is very slow compared to operator++(int).

template <typename T >
pointer Gtk::TreeIter< T >::operator-> ( ) const
inline
template <typename T >
template <typename T2 , typename = typename std::enable_if< std::is_same<T, TreeConstRow>::value && std::is_same<T2, TreeRow>::value, T2>::type>
TreeIter& Gtk::TreeIter< T >::operator= ( const TreeIter< T2 >&  src)

iterator to const_iterator assignment.

Friends And Related Function Documentation

template <typename T >
bool operator!= ( const TreeIterBase3 lhs,
const TreeIterBase3 rhs 
)
related
template <typename T >
bool operator== ( const TreeIterBase3 lhs,
const TreeIterBase3 rhs 
)
related