aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
gum::NodeGraphPartIterator Class Reference

Unsafe iterator on the node set of a graph. More...

#include <nodeGraphPart.h>

Inheritance diagram for gum::NodeGraphPartIterator:
Collaboration diagram for gum::NodeGraphPartIterator:

Public Types

using iterator_category = std::forward_iterator_tag
 types for STL compliance
using value_type = NodeId
 types for STL compliance
using reference = value_type&
 types for STL compliance
using const_reference = const value_type&
 types for STL compliance
using pointer = value_type*
 types for STL compliance
using const_pointer = const value_type*
 types for STL compliance
using difference_type = std::ptrdiff_t
 types for STL compliance

Public Member Functions

Constructors / Destructors
 NodeGraphPartIterator (const NodeGraphPart &nodes) noexcept
 Default constructor.
 NodeGraphPartIterator (const NodeGraphPartIterator &it) noexcept
 copy constructor
 NodeGraphPartIterator (NodeGraphPartIterator &&it) noexcept
 move constructor
virtual ~NodeGraphPartIterator () noexcept
 destructor
Operators
NodeGraphPartIteratoroperator= (const NodeGraphPartIterator &it) noexcept
 copy assignment operator
NodeGraphPartIteratoroperator= (NodeGraphPartIterator &&it) noexcept
 move assignment operator
bool operator== (const NodeGraphPartIterator &it) const noexcept
 checks whether two iterators point toward the same node
NodeGraphPartIteratoroperator++ () noexcept
 increment the iterator
value_type operator* () const
 dereferencing operator

Protected Member Functions

void setPos_ (NodeId id) noexcept
 this function is used by NodeGraphPart to update
void validate_ () noexcept
 ensure that the nodeId is either end() either a valid NodeId

Protected Attributes

const NodeGraphPartnodes_
 the nodegraphpart on which points the iterator
NodeId pos_ {0}
 the nodeid on which the iterator points currently
bool valid_ {false}

Friends

class NodeGraphPart

Detailed Description

Unsafe iterator on the node set of a graph.

Definition at line 69 of file nodeGraphPart.h.

Member Typedef Documentation

◆ const_pointer

types for STL compliance

Definition at line 80 of file nodeGraphPart.h.

◆ const_reference

types for STL compliance

Definition at line 78 of file nodeGraphPart.h.

◆ difference_type

types for STL compliance

Definition at line 81 of file nodeGraphPart.h.

◆ iterator_category

using gum::NodeGraphPartIterator::iterator_category = std::forward_iterator_tag

types for STL compliance

Definition at line 75 of file nodeGraphPart.h.

◆ pointer

types for STL compliance

Definition at line 79 of file nodeGraphPart.h.

◆ reference

types for STL compliance

Definition at line 77 of file nodeGraphPart.h.

◆ value_type

types for STL compliance

Definition at line 76 of file nodeGraphPart.h.

Constructor & Destructor Documentation

◆ NodeGraphPartIterator() [1/3]

INLINE gum::NodeGraphPartIterator::NodeGraphPartIterator ( const NodeGraphPart & nodes)
explicitnoexcept

Default constructor.

default constructor

Definition at line 76 of file nodeGraphPart_inl.h.

76 :
77 nodes_(&nodes) {
78 GUM_CONSTRUCTOR(NodeGraphPartIterator);
79 }
NodeGraphPartIterator(const NodeGraphPart &nodes) noexcept
Default constructor.
const NodeGraphPart * nodes_
the nodegraphpart on which points the iterator

References NodeGraphPartIterator(), NodeGraphPart, and nodes_.

Referenced by NodeGraphPartIterator(), NodeGraphPartIterator(), NodeGraphPartIterator(), gum::NodeGraphPartIteratorSafe::NodeGraphPartIteratorSafe(), gum::NodeGraphPartIteratorSafe::NodeGraphPartIteratorSafe(), gum::NodeGraphPartIteratorSafe::NodeGraphPartIteratorSafe(), ~NodeGraphPartIterator(), operator++(), operator=(), operator=(), and operator==().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NodeGraphPartIterator() [2/3]

INLINE gum::NodeGraphPartIterator::NodeGraphPartIterator ( const NodeGraphPartIterator & it)
noexcept

copy constructor

Definition at line 82 of file nodeGraphPart_inl.h.

82 :
83 nodes_(it.nodes_), pos_(it.pos_), valid_(it.valid_) {
84 GUM_CONS_CPY(NodeGraphPartIterator);
85 }
NodeId pos_
the nodeid on which the iterator points currently

References NodeGraphPartIterator(), nodes_, pos_, and valid_.

Here is the call graph for this function:

◆ NodeGraphPartIterator() [3/3]

INLINE gum::NodeGraphPartIterator::NodeGraphPartIterator ( NodeGraphPartIterator && it)
noexcept

move constructor

Definition at line 88 of file nodeGraphPart_inl.h.

88 :
89 nodes_(it.nodes_), pos_(it.pos_), valid_(it.valid_) {
90 GUM_CONS_MOV(NodeGraphPartIterator);
91 }

References NodeGraphPartIterator(), nodes_, pos_, and valid_.

Here is the call graph for this function:

◆ ~NodeGraphPartIterator()

INLINE gum::NodeGraphPartIterator::~NodeGraphPartIterator ( )
virtualnoexcept

destructor

Definition at line 94 of file nodeGraphPart_inl.h.

94 {
95 GUM_DESTRUCTOR(NodeGraphPartIterator);
96 }

References NodeGraphPartIterator().

Here is the call graph for this function:

Member Function Documentation

◆ operator*()

INLINE NodeId gum::NodeGraphPartIterator::operator* ( ) const

dereferencing operator

Definition at line 134 of file nodeGraphPart_inl.h.

134 {
135 if (!valid_) { GUM_ERROR(UndefinedIteratorValue, "This iterator is not valid !") }
136
137 return pos_;
138 }
#define GUM_ERROR(type, msg)
Definition exceptions.h:76

References GUM_ERROR, pos_, and valid_.

◆ operator++()

INLINE NodeGraphPartIterator & gum::NodeGraphPartIterator::operator++ ( )
noexcept

increment the iterator

Definition at line 127 of file nodeGraphPart_inl.h.

127 {
128 ++pos_;
129 validate_();
130 return *this;
131 }
void validate_() noexcept
ensure that the nodeId is either end() either a valid NodeId

References NodeGraphPartIterator(), pos_, and validate_().

Here is the call graph for this function:

◆ operator=() [1/2]

INLINE NodeGraphPartIterator & gum::NodeGraphPartIterator::operator= ( const NodeGraphPartIterator & it)
noexcept

copy assignment operator

Definition at line 100 of file nodeGraphPart_inl.h.

100 {
101 nodes_ = it.nodes_;
102 pos_ = it.pos_;
103 valid_ = it.valid_;
104 GUM_OP_CPY(NodeGraphPartIterator);
105
106 return *this;
107 }

References NodeGraphPartIterator(), nodes_, pos_, and valid_.

Referenced by gum::NodeGraphPartIteratorSafe::operator=(), and gum::NodeGraphPartIteratorSafe::operator=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [2/2]

INLINE NodeGraphPartIterator & gum::NodeGraphPartIterator::operator= ( NodeGraphPartIterator && it)
noexcept

move assignment operator

Definition at line 111 of file nodeGraphPart_inl.h.

111 {
112 nodes_ = it.nodes_;
113 pos_ = it.pos_;
114 valid_ = it.valid_;
115 GUM_OP_MOV(NodeGraphPartIterator);
116
117 return *this;
118 }

References NodeGraphPartIterator(), nodes_, pos_, and valid_.

Here is the call graph for this function:

◆ operator==()

INLINE bool gum::NodeGraphPartIterator::operator== ( const NodeGraphPartIterator & it) const
noexcept

checks whether two iterators point toward the same node

Definition at line 122 of file nodeGraphPart_inl.h.

122 {
123 return ((pos_ == it.pos_) && (valid_ == it.valid_) && (nodes_ == it.nodes_));
124 }

References NodeGraphPartIterator(), nodes_, pos_, and valid_.

Here is the call graph for this function:

◆ setPos_()

INLINE void gum::NodeGraphPartIterator::setPos_ ( NodeId id)
protectednoexcept

this function is used by NodeGraphPart to update

Definition at line 141 of file nodeGraphPart_inl.h.

141 {
142 pos_ = id;
143
144 if (pos_ >= nodes_->bound()) {
145 pos_ = nodes_->bound();
146 valid_ = false;
147 } else {
148 valid_ = nodes_->exists(pos_);
149 }
150 }

References nodes_, pos_, and valid_.

◆ validate_()

INLINE void gum::NodeGraphPartIterator::validate_ ( )
protectednoexcept

ensure that the nodeId is either end() either a valid NodeId

Definition at line 59 of file nodeGraphPart_inl.h.

59 {
60 valid_ = false;
61
62 if (pos_ > nodes_->bound()) { pos_ = nodes_->bound(); }
63
64 while (pos_ < nodes_->bound()) {
65 if (!nodes_->_inHoles_(pos_)) {
66 valid_ = true;
67 return;
68 }
69
70 ++pos_;
71 }
72 }

References nodes_, pos_, and valid_.

Referenced by gum::NodeGraphPart::begin(), gum::NodeGraphPart::beginSafe(), and operator++().

Here is the caller graph for this function:

◆ NodeGraphPart

friend class NodeGraphPart
friend

Definition at line 70 of file nodeGraphPart.h.

References NodeGraphPart.

Referenced by NodeGraphPartIterator(), and NodeGraphPart.

Member Data Documentation

◆ nodes_

◆ pos_

NodeId gum::NodeGraphPartIterator::pos_ {0}
protected

the nodeid on which the iterator points currently

Definition at line 139 of file nodeGraphPart.h.

139{0};

Referenced by NodeGraphPartIterator(), NodeGraphPartIterator(), operator*(), operator++(), operator=(), operator=(), operator==(), setPos_(), validate_(), and gum::NodeGraphPartIteratorSafe::whenNodeDeleted().

◆ valid_

bool gum::NodeGraphPartIterator::valid_ {false}
protected

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