aGrUM  0.14.2
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 NodeGraphPart_nodes
 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 55 of file nodeGraphPart.h.

Member Typedef Documentation

◆ const_pointer

types for STL compliance

Definition at line 66 of file nodeGraphPart.h.

◆ const_reference

types for STL compliance

Definition at line 64 of file nodeGraphPart.h.

◆ difference_type

types for STL compliance

Definition at line 67 of file nodeGraphPart.h.

◆ iterator_category

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

types for STL compliance

Definition at line 61 of file nodeGraphPart.h.

◆ pointer

types for STL compliance

Definition at line 65 of file nodeGraphPart.h.

◆ reference

types for STL compliance

Definition at line 63 of file nodeGraphPart.h.

◆ value_type

types for STL compliance

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

53  :
54  _nodes(&nodes) {
55  GUM_CONSTRUCTOR(NodeGraphPartIterator);
56  }
const NodeGraphPart * _nodes
the nodegraphpart on which points the iterator
NodeGraphPartIterator(const NodeGraphPart &nodes) noexcept
Default constructor.

◆ NodeGraphPartIterator() [2/3]

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

copy constructor

Definition at line 60 of file nodeGraphPart_inl.h.

61  :
62  _nodes(it._nodes),
63  _pos(it._pos), _valid(it._valid) {
64  GUM_CONS_CPY(NodeGraphPartIterator);
65  }
const NodeGraphPart * _nodes
the nodegraphpart on which points the iterator
NodeId _pos
the nodeid on which the iterator points currently
NodeGraphPartIterator(const NodeGraphPart &nodes) noexcept
Default constructor.

◆ NodeGraphPartIterator() [3/3]

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

move constructor

Definition at line 69 of file nodeGraphPart_inl.h.

70  :
71  _nodes(it._nodes),
72  _pos(it._pos), _valid(it._valid) {
73  GUM_CONS_MOV(NodeGraphPartIterator);
74  }
const NodeGraphPart * _nodes
the nodegraphpart on which points the iterator
NodeId _pos
the nodeid on which the iterator points currently
NodeGraphPartIterator(const NodeGraphPart &nodes) noexcept
Default constructor.

◆ ~NodeGraphPartIterator()

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

destructor

Definition at line 77 of file nodeGraphPart_inl.h.

References operator=().

77  {
78  GUM_DESTRUCTOR(NodeGraphPartIterator);
79  }
NodeGraphPartIterator(const NodeGraphPart &nodes) noexcept
Default constructor.
+ Here is the call graph for this function:

Member Function Documentation

◆ _setPos()

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

this function is used by NodeGraphPart to update

Definition at line 134 of file nodeGraphPart_inl.h.

References _nodes, _pos, _valid, gum::NodeGraphPart::bound(), and gum::NodeGraphPart::exists().

134  {
135  _pos = id;
136 
137  if (_pos >= _nodes->bound()) {
138  _pos = _nodes->bound();
139  _valid = false;
140  } else {
141  _valid = _nodes->exists(_pos);
142  }
143  }
bool exists(const NodeId id) const
alias for existsNode
const NodeGraphPart * _nodes
the nodegraphpart on which points the iterator
NodeId bound() const
returns a number n such that all node ids are strictly lower than n
NodeId _pos
the nodeid on which the iterator points currently
+ 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 35 of file nodeGraphPart_inl.h.

References gum::NodeGraphPart::__inHoles(), _nodes, _pos, _valid, and gum::NodeGraphPart::bound().

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

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

◆ operator!=()

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

checks whether two iterators point toward different nodes

Definition at line 112 of file nodeGraphPart_inl.h.

References operator==().

113  {
114  return !(operator==(it));
115  }
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 125 of file nodeGraphPart_inl.h.

References _pos, _valid, and GUM_ERROR.

125  {
126  if (!_valid) {
127  GUM_ERROR(UndefinedIteratorValue, "This iterator is not valid !");
128  }
129 
130  return _pos;
131  }
NodeId _pos
the nodeid on which the iterator points currently
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52

◆ operator++()

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

increment the iterator

Definition at line 118 of file nodeGraphPart_inl.h.

References _pos, and _validate().

118  {
119  ++_pos;
120  _validate();
121  return *this;
122  }
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 83 of file nodeGraphPart_inl.h.

References _nodes, _pos, and _valid.

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

83  {
84  _nodes = it._nodes;
85  _pos = it._pos;
86  _valid = it._valid;
87  GUM_OP_CPY(NodeGraphPartIterator);
88 
89  return *this;
90  }
const NodeGraphPart * _nodes
the nodegraphpart on which points the iterator
NodeId _pos
the nodeid on which the iterator points currently
NodeGraphPartIterator(const NodeGraphPart &nodes) noexcept
Default constructor.
+ 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 94 of file nodeGraphPart_inl.h.

References _nodes, _pos, and _valid.

94  {
95  _nodes = it._nodes;
96  _pos = it._pos;
97  _valid = it._valid;
98  GUM_OP_MOV(NodeGraphPartIterator);
99 
100  return *this;
101  }
const NodeGraphPart * _nodes
the nodegraphpart on which points the iterator
NodeId _pos
the nodeid on which the iterator points currently
NodeGraphPartIterator(const NodeGraphPart &nodes) noexcept
Default constructor.

◆ operator==()

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

checks whether two iterators point toward the same node

Definition at line 105 of file nodeGraphPart_inl.h.

References _nodes, _pos, and _valid.

Referenced by operator!=(), and gum::NodeGraphPart::operator!=().

106  {
107  return ((_pos == it._pos) && (_valid == it._valid) && (_nodes == it._nodes));
108  }
const NodeGraphPart * _nodes
the nodegraphpart on which points the iterator
NodeId _pos
the nodeid on which the iterator points currently
+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ NodeGraphPart

friend class NodeGraphPart
friend

Definition at line 56 of file nodeGraphPart.h.

Member Data Documentation

◆ _nodes

const NodeGraphPart* gum::NodeGraphPartIterator::_nodes
protected

the nodegraphpart on which points the iterator

Definition at line 124 of file nodeGraphPart.h.

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

◆ _pos

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

the nodeid on which the iterator points currently

Definition at line 127 of file nodeGraphPart.h.

Referenced by _setPos(), _validate(), operator*(), operator++(), operator=(), and operator==().

◆ _valid

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

Definition at line 130 of file nodeGraphPart.h.

Referenced by _setPos(), _validate(), operator*(), operator=(), and operator==().


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