Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
graph_iterators.h
Go to the documentation of this file.
32#pragma once
33
34#include <ogdf/basic/Reverse.h>
35#include <ogdf/basic/basic.h>
36
37#include <functional>
38
39namespace ogdf {
40
41namespace internal {
42
43template<class GraphObjectPtr, bool isReverse>
45template<class GraphObjectPtr>
47template<class GraphObjectPtr>
49
50template<class GraphObjectPtr, bool isReverse>
53
55
56public:
58
60
61 template<bool isArgReverse>
63
65 return m_ptr == other.m_ptr;
66 }
67
69 return m_ptr != other.m_ptr;
70 }
71
73
76 OGDF_ASSERT(m_ptr != nullptr);
77 m_ptr = isReverse ? m_ptr->pred() : m_ptr->succ();
78 return *this;
79 }
80
83 OGDF_ASSERT(m_ptr != nullptr);
85 m_ptr = isReverse ? m_ptr->pred() : m_ptr->succ();
86 return ptr;
87 }
88
91 OGDF_ASSERT(m_ptr != nullptr);
92 m_ptr = isReverse ? m_ptr->succ() : m_ptr->pred();
93 return *this;
94 }
95
98 OGDF_ASSERT(m_ptr != nullptr);
100 m_ptr = isReverse ? m_ptr->succ() : m_ptr->pred();
101 return ptr;
102 }
103};
104
105template<class ArrayType, bool isConst>
106class GraphArrayIteratorBase;
107template<class ArrayType>
109template<class ArrayType>
111
112template<class ArrayType, bool isConst>
115
116public:
118 using key_type = typename ArrayType::key_type;
120 using value_type = typename std::conditional<isConst, const typename ArrayType::value_type,
121 typename ArrayType::value_type>::type;
123 using array_pointer_type = typename std::conditional<isConst, const ArrayType*, ArrayType*>::type;
124
127
130
135
137 // gcc9 complains since it cannot match the templated constructor above (-Werror=deprecated-copy).
140
148
150 key_type key() const { return m_key; }
151
153 value_type& value() const { return (*m_array)[m_key]; }
154
156 value_type& operator*() const { return (*m_array)[m_key]; }
157
160 return m_key == iter.m_key && m_array == iter.m_array;
161 }
162
167
170 OGDF_ASSERT(m_key != nullptr);
171 m_key = ArrayType::findSuccKey(m_key);
172 return *this;
173 }
174
181
184 OGDF_ASSERT(m_key != nullptr);
185 m_key = ArrayType::findPredKey(m_key);
186 return *this;
187 }
188
195
196private:
199};
200
201}
202}
Implementation of the Reverse class for the reverse iteration of containers.
Basic declarations, included by all source files.
GraphArrayIteratorBase(const GraphArrayIteratorBase< ArrayType, isConst > &iter)
Copy constructor.
GraphArrayIteratorBase< ArrayType, isConst > & operator=(const GraphArrayIteratorBase< ArrayType, isConst > &iter)
Copy assignment operator.
key_type key() const
Index in m_array.
array_pointer_type m_array
The array.
GraphArrayIteratorBase< ArrayType, isConst > & operator--()
Decrement operator (prefix).
GraphArrayIteratorBase(const GraphArrayIteratorBase< ArrayType, isArgConst > &iter)
Constructor.
value_type & value() const
Value of m_array at index m_key.
bool operator!=(const GraphArrayIteratorBase< ArrayType, isConst > &iter) const
Inequality operator.
typename ArrayType::key_type key_type
Index type of the associated array.
GraphArrayIteratorBase< ArrayType, isConst > operator--(int)
Decrement operator (postfix).
typename std::conditional< isConst, const ArrayType *, ArrayType * >::type array_pointer_type
Type of the array.
GraphArrayIteratorBase< ArrayType, isConst > operator++(int)
Increment operator (postfix).
value_type & operator*() const
Value of m_array at index m_key.
typename std::conditional< isConst, const typename ArrayType::value_type, typename ArrayType::value_type >::type value_type
Value type of the associated array.
GraphArrayIteratorBase< ArrayType, isConst > & operator++()
Increment operator (prefix).
GraphArrayIteratorBase(key_type key, array_pointer_type a)
Constructor.
bool operator==(const GraphArrayIteratorBase< ArrayType, isConst > &iter) const
Equality operator.
GraphIteratorBase< GraphObjectPtr, isReverse > & operator++()
Increment operator (prefix).
GraphIteratorBase< GraphObjectPtr, isReverse > operator++(int)
Increment operator (postfix).
bool operator!=(const GraphIteratorBase< GraphObjectPtr, isReverse > &other) const
bool operator==(const GraphIteratorBase< GraphObjectPtr, isReverse > &other) const
GraphIteratorBase(GraphIteratorBase< GraphObjectPtr, isArgReverse > &it)
GraphIteratorBase< GraphObjectPtr, isReverse > & operator--()
Decrement operator (prefix).
GraphIteratorBase(GraphObjectPtr ptr)
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition basic.h:41
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.