timemory 3.3.0
Modular C++ Toolkit for Performance Analysis and Logging. Profiling API and Tools for C, C++, CUDA, Fortran, and Python. The C++ template API is essentially a framework to creating tools: it is designed to provide a unifying interface for recording various performance measurements alongside data logging and interfaces to other tools.
tim::graph< T, AllocatorT >::pre_order_iterator Class Reference

Depth-first iterator, first accessing the node, then its children. More...

#include "timemory/storage/graph.hpp"

+ Collaboration diagram for tim::graph< T, AllocatorT >::pre_order_iterator:

Public Types

typedef T value_type
 
typedef T * pointer
 
typedef T & reference
 
typedef size_t size_type
 
typedef ptrdiff_t difference_type
 
typedef std::bidirectional_iterator_tag iterator_category
 

Public Member Functions

 pre_order_iterator ()
 
 pre_order_iterator (graph_node *)
 
 pre_order_iterator (const iterator_base &)
 
 pre_order_iterator (const sibling_iterator &)
 
 pre_order_iterator (const pre_order_iterator &)=default
 
 pre_order_iterator (pre_order_iterator &&) noexcept=default
 
pre_order_iteratoroperator= (const pre_order_iterator &)=default
 
pre_order_iteratoroperator= (pre_order_iterator &&) noexcept=default
 
bool operator== (const pre_order_iterator &) const
 
bool operator!= (const pre_order_iterator &) const
 
pre_order_iteratoroperator++ ()
 
pre_order_iteratoroperator-- ()
 
pre_order_iterator operator++ (int)
 
pre_order_iterator operator-- (int)
 
pre_order_iteratoroperator+= (unsigned int)
 
pre_order_iteratoroperator-= (unsigned int)
 
pre_order_iterator operator+ (unsigned int)
 
pre_order_iteratornext_skip_children ()
 
 operator bool () const
 
T & operator* () const
 
T * operator-> () const
 
void skip_children ()
 When called, the next increment/decrement skips children of this node. More...
 
void skip_children (bool skip)
 
unsigned int number_of_children () const
 Number of children of the node pointed to by the iterator. More...
 
sibling_iterator begin () const
 
sibling_iterator end () const
 

Public Attributes

graph_nodenode = nullptr
 

Protected Attributes

bool m_skip_current_children = false
 

Detailed Description

template<typename T, typename AllocatorT>
class tim::graph< T, AllocatorT >::pre_order_iterator

Depth-first iterator, first accessing the node, then its children.

Definition at line 186 of file graph.hpp.

Member Typedef Documentation

◆ difference_type

template<typename T , typename AllocatorT >
typedef ptrdiff_t tim::graph< T, AllocatorT >::iterator_base::difference_type
inherited

Definition at line 145 of file graph.hpp.

◆ iterator_category

template<typename T , typename AllocatorT >
typedef std::bidirectional_iterator_tag tim::graph< T, AllocatorT >::iterator_base::iterator_category
inherited

Definition at line 146 of file graph.hpp.

◆ pointer

template<typename T , typename AllocatorT >
typedef T* tim::graph< T, AllocatorT >::iterator_base::pointer
inherited

Definition at line 142 of file graph.hpp.

◆ reference

template<typename T , typename AllocatorT >
typedef T& tim::graph< T, AllocatorT >::iterator_base::reference
inherited

Definition at line 143 of file graph.hpp.

◆ size_type

template<typename T , typename AllocatorT >
typedef size_t tim::graph< T, AllocatorT >::iterator_base::size_type
inherited

Definition at line 144 of file graph.hpp.

◆ value_type

template<typename T , typename AllocatorT >
typedef T tim::graph< T, AllocatorT >::iterator_base::value_type
inherited

Definition at line 141 of file graph.hpp.

Constructor & Destructor Documentation

◆ pre_order_iterator() [1/6]

◆ pre_order_iterator() [2/6]

template<typename T , typename AllocatorT >
tim::graph< T, AllocatorT >::pre_order_iterator::pre_order_iterator ( graph_node tn)

Definition at line 2576 of file graph.hpp.

2577: iterator_base(tn)
2578{}

◆ pre_order_iterator() [3/6]

template<typename T , typename AllocatorT >
tim::graph< T, AllocatorT >::pre_order_iterator::pre_order_iterator ( const iterator_base other)

Definition at line 2583 of file graph.hpp.

2584: iterator_base(other.node)
2585{}

◆ pre_order_iterator() [4/6]

template<typename T , typename AllocatorT >
tim::graph< T, AllocatorT >::pre_order_iterator::pre_order_iterator ( const sibling_iterator other)

Definition at line 2590 of file graph.hpp.

2592: iterator_base(other.node)
2593{
2594 if(this->node == nullptr)
2595 {
2596 if(other.range_last() != nullptr)
2597 {
2598 this->node = other.range_last();
2599 }
2600 else
2601 {
2602 this->node = other.m_parent;
2603 }
2604 this->skip_children();
2605 ++(*this);
2606 }
2607}
void skip_children()
When called, the next increment/decrement skips children of this node.
Definition: graph.hpp:2532

References tim::graph< T, AllocatorT >::sibling_iterator::m_parent, tim::graph< T, AllocatorT >::iterator_base::node, tim::graph< T, AllocatorT >::sibling_iterator::range_last(), and tim::graph< T, AllocatorT >::iterator_base::skip_children().

◆ pre_order_iterator() [5/6]

template<typename T , typename AllocatorT >
tim::graph< T, AllocatorT >::pre_order_iterator::pre_order_iterator ( const pre_order_iterator )
default

◆ pre_order_iterator() [6/6]

template<typename T , typename AllocatorT >
tim::graph< T, AllocatorT >::pre_order_iterator::pre_order_iterator ( pre_order_iterator &&  )
defaultnoexcept

Member Function Documentation

◆ begin()

template<typename T , typename AllocatorT >
graph< T, AllocatorT >::sibling_iterator tim::graph< T, AllocatorT >::iterator_base::begin
inherited

Definition at line 2507 of file graph.hpp.

2508{
2509 if(node->first_child == nullptr)
2510 return end();
2511
2512 sibling_iterator ret(node->first_child);
2513 ret.m_parent = this->node;
2514 return ret;
2515}
sibling_iterator end() const
Definition: graph.hpp:2521
tgraph_node< T > * first_child
Definition: graph.hpp:79

References tim::graph< T, AllocatorT >::end(), and tim::graph< T, AllocatorT >::sibling_iterator::m_parent.

Referenced by tim::graph< T, AllocatorT >::graph(), tim::graph< T, AllocatorT >::empty(), tim::graph< T, AllocatorT >::equal_subgraph(), tim::graph< T, AllocatorT >::merge(), and tim::graph< T, AllocatorT >::serialize().

◆ end()

template<typename T , typename AllocatorT >
graph< T, AllocatorT >::sibling_iterator tim::graph< T, AllocatorT >::iterator_base::end
inherited

◆ next_skip_children()

template<typename T , typename AllocatorT >
pre_order_iterator & tim::graph< T, AllocatorT >::pre_order_iterator::next_skip_children ( )

◆ number_of_children()

template<typename T , typename AllocatorT >
unsigned int tim::graph< T, AllocatorT >::iterator_base::number_of_children
inherited

Number of children of the node pointed to by the iterator.

Definition at line 2550 of file graph.hpp.

2551{
2553 if(pos == nullptr)
2554 return 0;
2555
2556 unsigned int ret = 1;
2557 while(pos != node->last_child)
2558 {
2559 ++ret;
2560 pos = pos->next_sibling;
2561 }
2562 return ret;
2563}
tgraph_node< T > graph_node
Definition: graph.hpp:117
tgraph_node< T > * last_child
Definition: graph.hpp:80
size_t pos
Definition: config.cpp:102

References tim::pos.

Referenced by tim::graph< T, AllocatorT >::equal(), and tim::graph< T, AllocatorT >::equal_subgraph().

◆ operator bool()

template<typename T , typename AllocatorT >
tim::graph< T, AllocatorT >::iterator_base::operator bool ( ) const
inlineinherited

Definition at line 159 of file graph.hpp.

159{ return node != nullptr; }

◆ operator!=()

template<typename T , typename AllocatorT >
bool tim::graph< T, AllocatorT >::pre_order_iterator::operator!= ( const pre_order_iterator other) const

Definition at line 2445 of file graph.hpp.

2447{
2448 if(other.node != this->node)
2449 {
2450 return true;
2451 }
2452 {
2453 return false;
2454 }
2455}

References tim::graph< T, AllocatorT >::iterator_base::node.

◆ operator*()

template<typename T , typename AllocatorT >
T & tim::graph< T, AllocatorT >::iterator_base::operator*
inherited

Definition at line 2428 of file graph.hpp.

2429{
2430 return node->data;
2431}

◆ operator+()

template<typename T , typename AllocatorT >
graph< T, AllocatorT >::pre_order_iterator tim::graph< T, AllocatorT >::pre_order_iterator::operator+ ( unsigned int  num)

Definition at line 2710 of file graph.hpp.

2711{
2712 auto itr = *this;
2713 while(num > 0)
2714 {
2715 ++itr;
2716 --num;
2717 }
2718 return itr;
2719}

◆ operator++() [1/2]

template<typename T , typename AllocatorT >
graph< T, AllocatorT >::pre_order_iterator & tim::graph< T, AllocatorT >::pre_order_iterator::operator++

Definition at line 2613 of file graph.hpp.

2614{
2615 assert(this->node != nullptr);
2616 if(!this->m_skip_current_children && this->node->first_child != nullptr)
2617 {
2618 this->node = this->node->first_child;
2619 }
2620 else
2621 {
2622 this->m_skip_current_children = false;
2623 while(this->node->next_sibling == nullptr)
2624 {
2625 this->node = this->node->parent;
2626 if(this->node == nullptr)
2627 return *this;
2628 }
2629 this->node = this->node->next_sibling;
2630 }
2631 return *this;
2632}
tgraph_node< T > * next_sibling
Definition: graph.hpp:82
tgraph_node< T > * parent
Definition: graph.hpp:78

◆ operator++() [2/2]

template<typename T , typename AllocatorT >
graph< T, AllocatorT >::pre_order_iterator tim::graph< T, AllocatorT >::pre_order_iterator::operator++ ( int  )

Definition at line 2660 of file graph.hpp.

2661{
2662 pre_order_iterator copy = *this;
2663 ++(*this);
2664 return copy;
2665}

◆ operator+=()

template<typename T , typename AllocatorT >
graph< T, AllocatorT >::pre_order_iterator & tim::graph< T, AllocatorT >::pre_order_iterator::operator+= ( unsigned int  num)

Definition at line 2682 of file graph.hpp.

2683{
2684 while(num > 0)
2685 {
2686 ++(*this);
2687 --num;
2688 }
2689 return (*this);
2690}

◆ operator--() [1/2]

template<typename T , typename AllocatorT >
graph< T, AllocatorT >::pre_order_iterator & tim::graph< T, AllocatorT >::pre_order_iterator::operator--

Definition at line 2638 of file graph.hpp.

2639{
2640 assert(this->node != nullptr);
2641 if(this->node->prev_sibling)
2642 {
2643 this->node = this->node->prev_sibling;
2644 while(this->node->last_child)
2645 this->node = this->node->last_child;
2646 }
2647 else
2648 {
2649 this->node = this->node->parent;
2650 if(this->node == nullptr)
2651 return *this;
2652 }
2653 return *this;
2654}
tgraph_node< T > * prev_sibling
Definition: graph.hpp:81

◆ operator--() [2/2]

template<typename T , typename AllocatorT >
graph< T, AllocatorT >::pre_order_iterator tim::graph< T, AllocatorT >::pre_order_iterator::operator-- ( int  )

Definition at line 2671 of file graph.hpp.

2672{
2673 pre_order_iterator copy = *this;
2674 --(*this);
2675 return copy;
2676}

◆ operator-=()

template<typename T , typename AllocatorT >
graph< T, AllocatorT >::pre_order_iterator & tim::graph< T, AllocatorT >::pre_order_iterator::operator-= ( unsigned int  num)

Definition at line 2696 of file graph.hpp.

2697{
2698 while(num > 0)
2699 {
2700 --(*this);
2701 --num;
2702 }
2703 return (*this);
2704}

◆ operator->()

template<typename T , typename AllocatorT >
T * tim::graph< T, AllocatorT >::iterator_base::operator->
inherited

Definition at line 2436 of file graph.hpp.

2437{
2438 return &(node->data);
2439}

◆ operator=() [1/2]

template<typename T , typename AllocatorT >
pre_order_iterator & tim::graph< T, AllocatorT >::pre_order_iterator::operator= ( const pre_order_iterator )
default

◆ operator=() [2/2]

template<typename T , typename AllocatorT >
pre_order_iterator & tim::graph< T, AllocatorT >::pre_order_iterator::operator= ( pre_order_iterator &&  )
defaultnoexcept

◆ operator==()

template<typename T , typename AllocatorT >
bool tim::graph< T, AllocatorT >::pre_order_iterator::operator== ( const pre_order_iterator other) const

Definition at line 2461 of file graph.hpp.

2463{
2464 if(other.node == this->node)
2465 {
2466 return true;
2467 }
2468 {
2469 return false;
2470 }
2471}

References tim::graph< T, AllocatorT >::iterator_base::node.

◆ skip_children() [1/2]

template<typename T , typename AllocatorT >
void tim::graph< T, AllocatorT >::iterator_base::skip_children
inherited

When called, the next increment/decrement skips children of this node.

Definition at line 2532 of file graph.hpp.

2533{
2535}

Referenced by tim::graph< T, AllocatorT >::pre_order_iterator::pre_order_iterator().

◆ skip_children() [2/2]

template<typename T , typename AllocatorT >
void tim::graph< T, AllocatorT >::iterator_base::skip_children ( bool  skip)
inherited

Definition at line 2541 of file graph.hpp.

2542{
2544}

Member Data Documentation

◆ m_skip_current_children

template<typename T , typename AllocatorT >
bool tim::graph< T, AllocatorT >::iterator_base::m_skip_current_children = false
protectedinherited

Definition at line 182 of file graph.hpp.

◆ node


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