aGrUM  0.20.3
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 Member Functions

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

Public Types

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

Protected Attributes

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

Protected Member Functions

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

Friends

class NodeGraphPart
 

Detailed Description

Unsafe iterator on the node set of a graph.

Definition at line 57 of file nodeGraphPart.h.

Member Typedef Documentation

◆ const_pointer

types for STL compliance

Definition at line 68 of file nodeGraphPart.h.

◆ const_reference

types for STL compliance

Definition at line 66 of file nodeGraphPart.h.

◆ difference_type

types for STL compliance

Definition at line 69 of file nodeGraphPart.h.

◆ iterator_category

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

types for STL compliance

Definition at line 63 of file nodeGraphPart.h.

◆ pointer

types for STL compliance

Definition at line 67 of file nodeGraphPart.h.

◆ reference

types for STL compliance

Definition at line 65 of file nodeGraphPart.h.

◆ value_type

types for STL compliance

Definition at line 64 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 54 of file nodeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

54  :
55  nodes_(&nodes) {
56  GUM_CONSTRUCTOR(NodeGraphPartIterator);
57  }
NodeGraphPartIterator(const NodeGraphPart &nodes) noexcept
Default constructor.
const NodeGraphPart * nodes_
the nodegraphpart on which points the iterator
+ Here is the call graph for this function:

◆ NodeGraphPartIterator() [2/3]

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

copy constructor

Definition at line 60 of file nodeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

60  :
61  nodes_(it.nodes_), pos_(it.pos_), valid_(it.valid_) {
62  GUM_CONS_CPY(NodeGraphPartIterator);
63  }
NodeId pos_
the nodeid on which the iterator points currently
NodeGraphPartIterator(const NodeGraphPart &nodes) noexcept
Default constructor.
const NodeGraphPart * nodes_
the nodegraphpart on which points the iterator
+ Here is the call graph for this function:

◆ NodeGraphPartIterator() [3/3]

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

move constructor

Definition at line 66 of file nodeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

66  :
67  nodes_(it.nodes_), pos_(it.pos_), valid_(it.valid_) {
68  GUM_CONS_MOV(NodeGraphPartIterator);
69  }
NodeId pos_
the nodeid on which the iterator points currently
NodeGraphPartIterator(const NodeGraphPart &nodes) noexcept
Default constructor.
const NodeGraphPart * nodes_
the nodegraphpart on which points the iterator
+ Here is the call graph for this function:

◆ ~NodeGraphPartIterator()

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

destructor

Definition at line 72 of file nodeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

72  {
73  GUM_DESTRUCTOR(NodeGraphPartIterator);
74  }
NodeGraphPartIterator(const NodeGraphPart &nodes) noexcept
Default constructor.
+ 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 106 of file nodeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

106  {
107  return !(operator==(it));
108  }
bool operator==(const NodeGraphPartIterator &it) const noexcept
checks whether two iterators point toward the same node
+ Here is the call graph for this function:

◆ operator*()

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

dereferencing operator

Definition at line 118 of file nodeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

118  {
119  if (!valid_) { GUM_ERROR(UndefinedIteratorValue, "This iterator is not valid !") }
120 
121  return pos_;
122  }
NodeId pos_
the nodeid on which the iterator points currently
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51
+ Here is the call graph for this function:

◆ operator++()

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

increment the iterator

Definition at line 111 of file nodeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

111  {
112  ++pos_;
113  validate_();
114  return *this;
115  }
void validate_() noexcept
ensure that the nodeId is either end() either a valid NodeId
NodeId pos_
the nodeid on which the iterator points currently
+ 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 78 of file nodeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

78  {
79  nodes_ = it.nodes_;
80  pos_ = it.pos_;
81  valid_ = it.valid_;
82  GUM_OP_CPY(NodeGraphPartIterator);
83 
84  return *this;
85  }
NodeId pos_
the nodeid on which the iterator points currently
NodeGraphPartIterator(const NodeGraphPart &nodes) noexcept
Default constructor.
const NodeGraphPart * nodes_
the nodegraphpart on which points the iterator
+ Here is the call graph for this function:

◆ operator=() [2/2]

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

move assignment operator

Definition at line 89 of file nodeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

89  {
90  nodes_ = it.nodes_;
91  pos_ = it.pos_;
92  valid_ = it.valid_;
93  GUM_OP_MOV(NodeGraphPartIterator);
94 
95  return *this;
96  }
NodeId pos_
the nodeid on which the iterator points currently
NodeGraphPartIterator(const NodeGraphPart &nodes) noexcept
Default constructor.
const NodeGraphPart * nodes_
the nodegraphpart on which points the iterator
+ 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 100 of file nodeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

100  {
101  return ((pos_ == it.pos_) && (valid_ == it.valid_) && (nodes_ == it.nodes_));
102  }
NodeId pos_
the nodeid on which the iterator points currently
const NodeGraphPart * nodes_
the nodegraphpart on which points the iterator
+ 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 125 of file nodeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

125  {
126  pos_ = id;
127 
128  if (pos_ >= nodes_->bound()) {
129  pos_ = nodes_->bound();
130  valid_ = false;
131  } else {
132  valid_ = nodes_->exists(pos_);
133  }
134  }
bool exists(const NodeId id) const
alias for existsNode
NodeId pos_
the nodeid on which the iterator points currently
NodeId bound() const
returns a number n such that all node ids are strictly lower than n
const NodeGraphPart * nodes_
the nodegraphpart on which points the iterator
+ Here is the call graph for this function:

◆ validate_()

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

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

Definition at line 37 of file nodeGraphPart_inl.h.

References gum::Set< Key, Alloc >::emplace().

37  {
38  valid_ = false;
39 
40  if (pos_ > nodes_->bound()) { pos_ = nodes_->bound(); }
41 
42  while (pos_ < nodes_->bound()) {
43  if (!nodes_->_inHoles_(pos_)) {
44  valid_ = true;
45  return;
46  }
47 
48  ++pos_;
49  }
50  }
NodeId pos_
the nodeid on which the iterator points currently
NodeId bound() const
returns a number n such that all node ids are strictly lower than n
bool _inHoles_(NodeId id) const
const NodeGraphPart * nodes_
the nodegraphpart on which points the iterator
+ Here is the call graph for this function:

Friends And Related Function Documentation

◆ NodeGraphPart

friend class NodeGraphPart
friend

Definition at line 58 of file nodeGraphPart.h.

Member Data Documentation

◆ nodes_

const NodeGraphPart* gum::NodeGraphPartIterator::nodes_
protected

the nodegraphpart on which points the iterator

Definition at line 126 of file nodeGraphPart.h.

◆ pos_

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

the nodeid on which the iterator points currently

Definition at line 129 of file nodeGraphPart.h.

◆ valid_

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

Definition at line 132 of file nodeGraphPart.h.


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