aGrUM  0.16.0
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 58 of file nodeGraphPart.h.

Member Typedef Documentation

◆ const_pointer

types for STL compliance

Definition at line 69 of file nodeGraphPart.h.

◆ const_reference

types for STL compliance

Definition at line 67 of file nodeGraphPart.h.

◆ difference_type

types for STL compliance

Definition at line 70 of file nodeGraphPart.h.

◆ iterator_category

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

types for STL compliance

Definition at line 64 of file nodeGraphPart.h.

◆ pointer

types for STL compliance

Definition at line 68 of file nodeGraphPart.h.

◆ reference

types for STL compliance

Definition at line 66 of file nodeGraphPart.h.

◆ value_type

types for STL compliance

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

56  :
57  _nodes(&nodes) {
58  GUM_CONSTRUCTOR(NodeGraphPartIterator);
59  }
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 63 of file nodeGraphPart_inl.h.

64  :
65  _nodes(it._nodes),
66  _pos(it._pos), _valid(it._valid) {
67  GUM_CONS_CPY(NodeGraphPartIterator);
68  }
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 72 of file nodeGraphPart_inl.h.

73  :
74  _nodes(it._nodes),
75  _pos(it._pos), _valid(it._valid) {
76  GUM_CONS_MOV(NodeGraphPartIterator);
77  }
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 80 of file nodeGraphPart_inl.h.

References operator=().

80  {
81  GUM_DESTRUCTOR(NodeGraphPartIterator);
82  }
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 137 of file nodeGraphPart_inl.h.

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

137  {
138  _pos = id;
139 
140  if (_pos >= _nodes->bound()) {
141  _pos = _nodes->bound();
142  _valid = false;
143  } else {
144  _valid = _nodes->exists(_pos);
145  }
146  }
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 38 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++().

38  {
39  _valid = false;
40 
41  if (_pos > _nodes->bound()) { _pos = _nodes->bound(); }
42 
43  while (_pos < _nodes->bound()) {
44  if (!_nodes->__inHoles(_pos)) {
45  _valid = true;
46  return;
47  }
48 
49  ++_pos;
50  }
51  }
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 115 of file nodeGraphPart_inl.h.

References operator==().

116  {
117  return !(operator==(it));
118  }
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 128 of file nodeGraphPart_inl.h.

References _pos, _valid, and GUM_ERROR.

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

◆ operator++()

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

increment the iterator

Definition at line 121 of file nodeGraphPart_inl.h.

References _pos, and _validate().

121  {
122  ++_pos;
123  _validate();
124  return *this;
125  }
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 86 of file nodeGraphPart_inl.h.

References _nodes, _pos, and _valid.

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

86  {
87  _nodes = it._nodes;
88  _pos = it._pos;
89  _valid = it._valid;
90  GUM_OP_CPY(NodeGraphPartIterator);
91 
92  return *this;
93  }
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 97 of file nodeGraphPart_inl.h.

References _nodes, _pos, and _valid.

97  {
98  _nodes = it._nodes;
99  _pos = it._pos;
100  _valid = it._valid;
101  GUM_OP_MOV(NodeGraphPartIterator);
102 
103  return *this;
104  }
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 108 of file nodeGraphPart_inl.h.

References _nodes, _pos, and _valid.

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

109  {
110  return ((_pos == it._pos) && (_valid == it._valid) && (_nodes == it._nodes));
111  }
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 59 of file nodeGraphPart.h.

Member Data Documentation

◆ _nodes

const NodeGraphPart* gum::NodeGraphPartIterator::_nodes
protected

the nodegraphpart on which points the iterator

Definition at line 127 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 130 of file nodeGraphPart.h.

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

◆ _valid

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

Definition at line 133 of file nodeGraphPart.h.

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


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