Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
FMEFunctional.h
Go to the documentation of this file.
1
32#pragma once
33
34#include <ogdf/basic/basic.h>
35
36namespace ogdf {
37namespace fast_multipole_embedder {
38
40struct do_nothing {
41 template<typename A>
42 inline void operator()(A a) { }
43
44 template<typename A, typename B>
45 inline void operator()(A a, B b) { }
46};
47
49template<bool result>
51 template<typename A>
52 inline bool operator()(A a) {
53 return result;
54 }
55
56 template<typename A, typename B>
57 inline bool operator()(A a, B b) {
58 return result;
59 }
60};
61
65
67template<typename Func>
70
71 not_condition_functor(const Func& cond) : cond_func(cond) { }
72
73 template<typename A>
74 inline bool operator()(A a) {
75 return !cond_func(a);
76 }
77
78 template<typename A, typename B>
79 inline void operator()(A a, B b) {
80 return !cond_func(a, b);
81 }
82};
83
85template<typename Func>
87 return not_condition_functor<Func>(func);
88}
89
91template<typename CondType, typename ThenType, typename ElseType = do_nothing>
96
98
100 : condFunc(c), thenFunc(f1), elseFunc(f2) { }
101
102 template<typename A>
103 inline void operator()(A a) {
104 if (condFunc(a)) {
105 thenFunc(a);
106 } else {
107 elseFunc(a);
108 }
109 }
110
111 template<typename A, typename B>
112 inline void operator()(A a, B b) {
113 if (condFunc(a, b)) {
114 thenFunc(a, b);
115 } else {
116 elseFunc(a, b);
117 }
118 }
119};
120
122template<typename CondType, typename ThenType, typename ElseType>
124 const ThenType& thenFunc, const ElseType& elseFunc) {
125 return if_then_else_functor<CondType, ThenType, ElseType>(cond, thenFunc, elseFunc);
126}
127
129template<typename CondType, typename ThenType>
131 const ThenType& thenFunc) {
132 return if_then_else_functor<CondType, ThenType>(cond, thenFunc);
133}
134
136template<typename F, typename A>
141
142 template<typename B>
143 inline void operator()(B second) {
144 func(first, second);
145 }
146};
147
149template<typename F, typename A>
151 return pair_call_functor<F, A>(f, a);
152}
153
155template<typename FuncFirst, typename FuncSecond>
159
161 : firstFunc(first), secondFunc(second) {};
162
163 template<typename A>
164 void operator()(A a) {
165 firstFunc(a);
166 secondFunc(a);
167 }
168
169 template<typename A, typename B>
170 void operator()(A a, B b) {
171 firstFunc(a, b);
172 secondFunc(a, b);
173 }
174};
175
177template<typename FuncFirst, typename FuncSecond>
182
184template<typename Func>
187
189
190 template<typename A, typename B>
191 void operator()(A a, B b) {
192 func(a, b);
193 func(b, a);
194 }
195};
196
198template<typename Func>
202
204template<typename T>
206 const T* a;
209
212 min_value = a[0];
213 max_value = a[0];
214 }
215
216 inline void operator()(uint32_t i) {
219 }
220};
221
222}
223}
Basic declarations, included by all source files.
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
static pair_call_functor< F, A > pair_call(F f, A a)
creates a pair call resulting in a call f(a, *)
static if_then_else_functor< CondType, ThenType > if_then(const CondType &cond, const ThenType &thenFunc)
creates an if then functor with a condition and a then functor
static if_then_else_functor< CondType, ThenType, ElseType > if_then_else(const CondType &cond, const ThenType &thenFunc, const ElseType &elseFunc)
creates an if then else functor with a condition and a then and an else functor
static pair_vice_versa_functor< Func > pair_vice_versa(const Func &f)
creates a functor for invoking a functor for a pair(u,v) and then (v,u)
static not_condition_functor< Func > not_condition(const Func &func)
creator of the negator
static composition_functor< FuncFirst, FuncSecond > func_comp(const FuncFirst &first, const FuncSecond &second)
create a functor composition of two functors
The namespace for all OGDF objects.
Functor for composing two other functors.
composition_functor(const FuncFirst &first, const FuncSecond &second)
condition functor for returning a constant boolean value
the useless do nothing function
Functor for conditional usage of a functor.
if_then_else_functor(const CondType &c, const ThenType &f1, const ElseType &f2)
if_then_else_functor(const CondType &c, const ThenType &f1)
generic min max functor for an array
min_max_functor(const T *ptr, T &min_var, T &max_var)
helper functor to generate a pair as parameters
functor for invoking a functor for a pair(u,v) and then (v,u)