aGrUM 2.3.2
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
bool operator!= (const NodeGraphPartIterator &it) const noexcept
 checks whether two iterators point toward different nodes
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 75 of file nodeGraphPart.h.

Member Typedef Documentation

◆ const_pointer

types for STL compliance

Definition at line 86 of file nodeGraphPart.h.

◆ const_reference

types for STL compliance

Definition at line 84 of file nodeGraphPart.h.

◆ difference_type

types for STL compliance

Definition at line 87 of file nodeGraphPart.h.

◆ iterator_category

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

types for STL compliance

Definition at line 81 of file nodeGraphPart.h.

◆ pointer

types for STL compliance

Definition at line 85 of file nodeGraphPart.h.

◆ reference

types for STL compliance

Definition at line 83 of file nodeGraphPart.h.

◆ value_type

types for STL compliance

Definition at line 82 of file nodeGraphPart.h.

Constructor & Destructor Documentation

◆ NodeGraphPartIterator() [1/3]

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

Default constructor.

default constructor

Definition at line 75 of file nodeGraphPart_inl.h.

75 :
76 nodes_(&nodes) {
77 GUM_CONSTRUCTOR(NodeGraphPartIterator);
78 }
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=(), 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 81 of file nodeGraphPart_inl.h.

81 :
82 nodes_(it.nodes_), pos_(it.pos_), valid_(it.valid_) {
83 GUM_CONS_CPY(NodeGraphPartIterator);
84 }
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 87 of file nodeGraphPart_inl.h.

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

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

Here is the call graph for this function:

◆ ~NodeGraphPartIterator()

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

destructor

Definition at line 93 of file nodeGraphPart_inl.h.

93 {
94 GUM_DESTRUCTOR(NodeGraphPartIterator);
95 }

References NodeGraphPartIterator().

Here is the call graph for this function:

Member Function Documentation

◆ operator!=()

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

checks whether two iterators point toward different nodes

Definition at line 127 of file nodeGraphPart_inl.h.

127 {
128 return !(operator==(it));
129 }
bool operator==(const NodeGraphPartIterator &it) const noexcept
checks whether two iterators point toward the same node

References NodeGraphPartIterator(), and gum::operator==().

Here is the call graph for this function:

◆ operator*()

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

dereferencing operator

Definition at line 139 of file nodeGraphPart_inl.h.

139 {
140 if (!valid_) { GUM_ERROR(UndefinedIteratorValue, "This iterator is not valid !") }
141
142 return pos_;
143 }
#define GUM_ERROR(type, msg)
Definition exceptions.h:72

References GUM_ERROR, pos_, and valid_.

◆ operator++()

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

increment the iterator

Definition at line 132 of file nodeGraphPart_inl.h.

132 {
133 ++pos_;
134 validate_();
135 return *this;
136 }
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 99 of file nodeGraphPart_inl.h.

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

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 110 of file nodeGraphPart_inl.h.

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

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 121 of file nodeGraphPart_inl.h.

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

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 146 of file nodeGraphPart_inl.h.

146 {
147 pos_ = id;
148
149 if (pos_ >= nodes_->bound()) {
150 pos_ = nodes_->bound();
151 valid_ = false;
152 } else {
153 valid_ = nodes_->exists(pos_);
154 }
155 }

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 58 of file nodeGraphPart_inl.h.

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

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 76 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 147 of file nodeGraphPart.h.

147{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: