Krita Source Code Documentation
Loading...
Searching...
No Matches
KisForestDetail::ChildIterator< T, is_const > Class Template Reference

#include <KisForest.h>

+ Inheritance diagram for KisForestDetail::ChildIterator< T, is_const >:

Public Types

using NodeType = typename BaseClass::NodeType
 
using RootNodeType = std::add_const_if_t<is_const, RootNode<T>>
 
- Public Types inherited from KisForestDetail::BaseIterator< ChildIterator< T, is_const >, T, boost::bidirectional_traversal_tag, is_const >
using NodeType
 
using value_type
 

Public Member Functions

 ChildIterator (NodeType *node, RootNodeType *parent, int offsetToParent)
 
 operator ChildIterator< T, true > () const
 
- Public Member Functions inherited from KisForestDetail::BaseIterator< ChildIterator< T, is_const >, T, boost::bidirectional_traversal_tag, is_const >
 BaseIterator (NodeType *node)
 
NodeTypenode () const
 

Private Types

using BaseClass
 

Private Member Functions

void decrement ()
 
bool equal (const ChildIterator< T, is_const > &other) const
 
void increment ()
 

Private Attributes

int m_offsetToParent
 
RootNodeTypem_parent
 

Friends

class boost::iterator_core_access
 
template<typename X , bool c>
ChildIterator< X, c > childBegin (const ChildIterator< X, c > &it)
 
template<typename X , bool c>
ChildIterator< X, c > childEnd (const ChildIterator< X, c > &it)
 
template<typename X >
class Forest
 
template<typename X , bool c>
QDebug operator<< (QDebug dbg, const ChildIterator< X, c > &it)
 
template<typename X , bool c>
ChildIterator< X, c > parent (const ChildIterator< X, c > &it)
 
template<typename X , bool c>
ChildIterator< X, c > siblingBegin (const ChildIterator< X, c > &it)
 
template<typename X , bool c>
ChildIterator< X, c > siblingEnd (const ChildIterator< X, c > &it)
 

Additional Inherited Members

- Protected Attributes inherited from KisForestDetail::BaseIterator< ChildIterator< T, is_const >, T, boost::bidirectional_traversal_tag, is_const >
NodeTypem_node
 

Detailed Description

template<typename T, bool is_const>
class KisForestDetail::ChildIterator< T, is_const >

Child iterator is used to traverse all the children of the current node. It models BidirectionalIterator concept, so you can traverse with it in both directions.

// Forest:
//
// 0 1
// 2
// 3 5 6
// 7
// 4
// 8 9
// 10
KisForest<int>::iterator it0 = findValue(forest, 0);
// iterate through all the children of '0'
for (auto it = childBegin(it0); it != childEnd(it0); ++it) {
qDebug() << *it;
}
// prints: 1,2,3,4
friend ChildIterator< X, c > childBegin(const ChildIterator< X, c > &it)
friend ChildIterator< X, c > childEnd(const ChildIterator< X, c > &it)

It is also possible to convert any iterator type into child iterator via siblingCurrent() function.

// Forest:
//
// 0 1
// 2
// 3 5 6
// 7
// 4
// 8 9
// 10
KisForest<int>::iterator it2 = findValue(forest, 2);
// iterate the children of '0' from '2' to '4'
for (auto it = siblingCurrent(it2); it != siblingEnd(it2); ++it) {
qDebug() << *it;
}
// prints: 2,3,4
friend ChildIterator< X, c > siblingEnd(const ChildIterator< X, c > &it)
ChildIterator< value_type, is_const > siblingCurrent(ChildIterator< value_type, is_const > it)
Definition KisForest.h:240

WARNING: converting end() iterator to other iterator types currently leads to undefined behavior.

Definition at line 160 of file KisForest.h.

Member Typedef Documentation

◆ BaseClass

template<typename T , bool is_const>
using KisForestDetail::ChildIterator< T, is_const >::BaseClass
private
Initial value:
BaseIterator <ChildIterator<T, is_const>,
T,
boost::bidirectional_traversal_tag,
is_const>

Definition at line 166 of file KisForest.h.

◆ NodeType

template<typename T , bool is_const>
using KisForestDetail::ChildIterator< T, is_const >::NodeType = typename BaseClass::NodeType

Definition at line 174 of file KisForest.h.

◆ RootNodeType

template<typename T , bool is_const>
using KisForestDetail::ChildIterator< T, is_const >::RootNodeType = std::add_const_if_t<is_const, RootNode<T>>

Definition at line 173 of file KisForest.h.

Constructor & Destructor Documentation

◆ ChildIterator()

template<typename T , bool is_const>
KisForestDetail::ChildIterator< T, is_const >::ChildIterator ( NodeType * node,
RootNodeType * parent,
int offsetToParent )
inline

Definition at line 176 of file KisForest.h.

177 : BaseClass(node),
179 m_offsetToParent(offsetToParent)
180 {
181 }
BaseIterator< ChildIterator< T, is_const >, T, boost::bidirectional_traversal_tag, is_const > BaseClass
Definition KisForest.h:166
friend ChildIterator< X, c > parent(const ChildIterator< X, c > &it)

Member Function Documentation

◆ decrement()

◆ equal()

template<typename T , bool is_const>
bool KisForestDetail::ChildIterator< T, is_const >::equal ( const ChildIterator< T, is_const > & other) const
inlineprivate

◆ increment()

template<typename T , bool is_const>
void KisForestDetail::ChildIterator< T, is_const >::increment ( )
inlineprivate

◆ operator ChildIterator< T, true >()

Friends And Related Symbol Documentation

◆ boost::iterator_core_access

template<typename T , bool is_const>
friend class boost::iterator_core_access
friend

Definition at line 188 of file KisForest.h.

◆ childBegin

template<typename T , bool is_const>
template<typename X , bool c>
ChildIterator< X, c > childBegin ( const ChildIterator< X, c > & it)
friend

◆ childEnd

template<typename T , bool is_const>
template<typename X , bool c>
ChildIterator< X, c > childEnd ( const ChildIterator< X, c > & it)
friend

◆ Forest

template<typename T , bool is_const>
template<typename X >
friend class Forest
friend

Definition at line 202 of file KisForest.h.

◆ operator<<

template<typename T , bool is_const>
template<typename X , bool c>
QDebug operator<< ( QDebug dbg,
const ChildIterator< X, c > & it )
friend

◆ parent

template<typename T , bool is_const>
template<typename X , bool c>
ChildIterator< X, c > parent ( const ChildIterator< X, c > & it)
friend

◆ siblingBegin

template<typename T , bool is_const>
template<typename X , bool c>
ChildIterator< X, c > siblingBegin ( const ChildIterator< X, c > & it)
friend

◆ siblingEnd

template<typename T , bool is_const>
template<typename X , bool c>
ChildIterator< X, c > siblingEnd ( const ChildIterator< X, c > & it)
friend

Member Data Documentation

◆ m_offsetToParent

template<typename T , bool is_const>
int KisForestDetail::ChildIterator< T, is_const >::m_offsetToParent
private

Definition at line 224 of file KisForest.h.

◆ m_parent

template<typename T , bool is_const>
RootNodeType* KisForestDetail::ChildIterator< T, is_const >::m_parent
private

Definition at line 223 of file KisForest.h.


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