aGrUM  0.16.0
graphChange_inl.h
Go to the documentation of this file.
1 
31 #ifndef DOXYGEN_SHOULD_SKIP_THIS
32 
33 namespace gum {
34 
35  namespace learning {
36 
39  NodeId node1,
40  NodeId node2) noexcept :
41  __type{type},
42  __node1{node1}, __node2{node2} {
43  GUM_CONSTRUCTOR(GraphChange);
44  }
45 
47  INLINE GraphChange::GraphChange(const GraphChange& from) noexcept :
48  __type{from.__type}, __node1{from.__node1}, __node2{from.__node2} {
49  GUM_CONS_CPY(GraphChange);
50  }
51 
53  INLINE GraphChange::GraphChange(GraphChange&& from) noexcept :
54  __type{from.__type}, __node1{from.__node1}, __node2{from.__node2} {
55  GUM_CONS_MOV(GraphChange);
56  }
57 
59  INLINE GraphChange::~GraphChange() noexcept { GUM_DESTRUCTOR(GraphChange); }
60 
62  INLINE GraphChange& GraphChange::operator=(const GraphChange& from) noexcept {
63  __type = from.__type;
64  __node1 = from.__node1;
65  __node2 = from.__node2;
66  return *this;
67  }
68 
70  INLINE GraphChange& GraphChange::operator=(GraphChange&& from) noexcept {
71  __type = from.__type;
72  __node1 = from.__node1;
73  __node2 = from.__node2;
74  return *this;
75  }
76 
78  INLINE GraphChangeType GraphChange::type() const noexcept { return __type; }
79 
81  INLINE NodeId GraphChange::node1() const noexcept { return __node1; }
82 
84  INLINE NodeId GraphChange::node2() const noexcept { return __node2; }
85 
87  INLINE bool GraphChange::operator==(const GraphChange& from) const noexcept {
88  return ((__node1 == from.__node1) && (__node2 == from.__node2)
89  && (__type == from.__type));
90  }
91 
93  INLINE bool GraphChange::operator!=(const GraphChange& from) const noexcept {
94  return !operator==(from);
95  }
96 
97  // ===========================================================================
98 
100  INLINE ArcAddition::ArcAddition(NodeId node1, NodeId node2) noexcept :
102  // do not use GUM_CONSTRUCTOR here because, to speed up GraphChange's
103  // destructor, we did not make the latter's destructor virtual.
104  }
105 
107  INLINE ArcAddition::ArcAddition(const ArcAddition& from) noexcept :
108  GraphChange(from) {
109  // do not use GUM_CONS_CPY here because, to speed up GraphChange's
110  // destructor, we did not make the latter's destructor virtual.
111  }
112 
114  INLINE ArcAddition::ArcAddition(ArcAddition&& from) noexcept :
115  GraphChange(std::move(from)) {
116  // do not use GUM_CONS_MOV here because, to speed up GraphChange's
117  // destructor, we did not make the latter's destructor virtual.
118  }
119 
121  INLINE ArcAddition::~ArcAddition() noexcept {
122  // do not use GUM_DESTRUCTOR here because, to speed up GraphChange's
123  // destructor, we did not make the latter's destructor virtual.
124  }
125 
127  INLINE ArcAddition& ArcAddition::operator=(const ArcAddition& from) noexcept {
129  return *this;
130  }
131 
133  INLINE ArcAddition& ArcAddition::operator=(ArcAddition&& from) noexcept {
134  GraphChange::operator=(std::move(from));
135  return *this;
136  }
137 
139  INLINE bool ArcAddition::operator==(const ArcAddition& from) const noexcept {
140  return ((node1() == from.node1()) && (node2() == from.node2()));
141  }
142 
144  INLINE bool ArcAddition::operator!=(const ArcAddition& from) const noexcept {
145  return !operator==(from);
146  }
147 
148  // ===========================================================================
149 
151  INLINE ArcDeletion::ArcDeletion(NodeId node1, NodeId node2) noexcept :
153  // do not use GUM_CONSTRUCTOR here because, to speed up GraphChange's
154  // destructor, we did not make the latter's destructor virtual.
155  }
156 
158  INLINE ArcDeletion::ArcDeletion(const ArcDeletion& from) noexcept :
159  GraphChange(from) {
160  // do not use GUM_CONS_CPY here because, to speed up GraphChange's
161  // destructor, we did not make the latter's destructor virtual.
162  }
163 
165  INLINE ArcDeletion::ArcDeletion(ArcDeletion&& from) noexcept :
166  GraphChange(std::move(from)) {
167  // do not use GUM_CONS_MOV here because, to speed up GraphChange's
168  // destructor, we did not make the latter's destructor virtual.
169  }
170 
172  INLINE ArcDeletion::~ArcDeletion() noexcept {
173  // do not use GUM_DESTRUCTOR here because, to speed up GraphChange's
174  // destructor, we did not make the latter's destructor virtual.
175  }
176 
178  INLINE ArcDeletion& ArcDeletion::operator=(const ArcDeletion& from) noexcept {
180  return *this;
181  }
182 
184  INLINE ArcDeletion& ArcDeletion::operator=(ArcDeletion&& from) noexcept {
185  GraphChange::operator=(std::move(from));
186  return *this;
187  }
188 
190  INLINE bool ArcDeletion::operator==(const ArcDeletion& from) const noexcept {
191  return ((node1() == from.node1()) && (node2() == from.node2()));
192  }
193 
195  INLINE bool ArcDeletion::operator!=(const ArcDeletion& from) const noexcept {
196  return !operator==(from);
197  }
198 
199  // ===========================================================================
200 
202  INLINE ArcReversal::ArcReversal(NodeId node1, NodeId node2) noexcept :
204  // do not use GUM_CONSTRUCTOR here because, to speed up GraphChange's
205  // destructor, we did not make the latter's destructor virtual.
206  }
207 
209  INLINE ArcReversal::ArcReversal(const ArcReversal& from) noexcept :
210  GraphChange(from) {
211  // do not use GUM_CONS_CPY here because, to speed up GraphChange's
212  // destructor, we did not make the latter's destructor virtual.
213  }
214 
216  INLINE ArcReversal::ArcReversal(ArcReversal&& from) noexcept :
217  GraphChange(std::move(from)) {
218  // do not use GUM_CONS_MOV here because, to speed up GraphChange's
219  // destructor, we did not make the latter's destructor virtual.
220  }
221 
223  INLINE ArcReversal::~ArcReversal() noexcept {
224  // do not use GUM_DESTRUCTOR here because, to speed up GraphChange's
225  // destructor, we did not make the latter's destructor virtual.
226  }
227 
229  INLINE ArcReversal& ArcReversal::operator=(const ArcReversal& from) noexcept {
231  return *this;
232  }
233 
235  INLINE ArcReversal& ArcReversal::operator=(ArcReversal&& from) noexcept {
236  GraphChange::operator=(std::move(from));
237  return *this;
238  }
239 
241  INLINE bool ArcReversal::operator==(const ArcReversal& from) const noexcept {
242  return ((node1() == from.node1()) && (node2() == from.node2()));
243  }
244 
246  INLINE bool ArcReversal::operator!=(const ArcReversal& from) const noexcept {
247  return !operator==(from);
248  }
249 
250  // ===========================================================================
251 
255  // do not use GUM_CONSTRUCTOR here because, to speed up GraphChange's
256  // destructor, we did not make the latter's destructor virtual.
257  }
258 
260  INLINE EdgeAddition::EdgeAddition(const EdgeAddition& from) noexcept :
261  GraphChange(from) {
262  // do not use GUM_CONS_CPY here because, to speed up GraphChange's
263  // destructor, we did not make the latter's destructor virtual.
264  }
265 
267  INLINE EdgeAddition::EdgeAddition(EdgeAddition&& from) noexcept :
268  GraphChange(std::move(from)) {
269  // do not use GUM_CONS_MOV here because, to speed up GraphChange's
270  // destructor, we did not make the latter's destructor virtual.
271  }
272 
274  INLINE EdgeAddition::~EdgeAddition() noexcept {
275  // do not use GUM_DESTRUCTOR here because, to speed up GraphChange's
276  // destructor, we did not make the latter's destructor virtual.
277  }
278 
280  INLINE EdgeAddition& EdgeAddition::
281  operator=(const EdgeAddition& from) noexcept {
283  return *this;
284  }
285 
287  INLINE EdgeAddition& EdgeAddition::operator=(EdgeAddition&& from) noexcept {
288  GraphChange::operator=(std::move(from));
289  return *this;
290  }
291 
293  INLINE bool EdgeAddition::operator==(const EdgeAddition& from) const noexcept {
294  return (((node1() == from.node1()) && (node2() == from.node2()))
295  || ((node1() == from.node2()) && (node2() == from.node1())));
296  }
297 
299  INLINE bool EdgeAddition::operator!=(const EdgeAddition& from) const noexcept {
300  return !operator==(from);
301  }
302 
303  // ===========================================================================
304 
308  // do not use GUM_CONSTRUCTOR here because, to speed up GraphChange's
309  // destructor, we did not make the latter's destructor virtual.
310  }
311 
313  INLINE EdgeDeletion::EdgeDeletion(const EdgeDeletion& from) noexcept :
314  GraphChange(from) {
315  // do not use GUM_CONS_CPY here because, to speed up GraphChange's
316  // destructor, we did not make the latter's destructor virtual.
317  }
318 
320  INLINE EdgeDeletion::EdgeDeletion(EdgeDeletion&& from) noexcept :
321  GraphChange(std::move(from)) {
322  // do not use GUM_CONS_MOV here because, to speed up GraphChange's
323  // destructor, we did not make the latter's destructor virtual.
324  }
325 
327  INLINE EdgeDeletion::~EdgeDeletion() noexcept {
328  // do not use GUM_DESTRUCTOR here because, to speed up GraphChange's
329  // destructor, we did not make the latter's destructor virtual.
330  }
331 
333  INLINE EdgeDeletion& EdgeDeletion::
334  operator=(const EdgeDeletion& from) noexcept {
336  return *this;
337  }
338 
340  INLINE EdgeDeletion& EdgeDeletion::operator=(EdgeDeletion&& from) noexcept {
341  GraphChange::operator=(std::move(from));
342  return *this;
343  }
344 
346  INLINE bool EdgeDeletion::operator==(const EdgeDeletion& from) const noexcept {
347  return (((node1() == from.node1()) && (node2() == from.node2()))
348  || ((node1() == from.node2()) && (node2() == from.node1())));
349  }
350 
352  INLINE bool EdgeDeletion::operator!=(const EdgeDeletion& from) const noexcept {
353  return !operator==(from);
354  }
355 
356 
357  } /* namespace learning */
358 
359 
360  // ===========================================================================
361 
362  // Returns the value of a key as a Size.
364  const learning::GraphChange& key) {
365  return Size(key.node1()) * HashFuncConst::gold
366  + Size(key.node2()) * HashFuncConst::pi;
367  }
368 
370  INLINE Size HashFunc< learning::GraphChange >::
371  operator()(const learning::GraphChange& key) const {
372  return castToSize(key) >> this->_right_shift;
373  }
374 
375 
376  // Returns the value of a key as a Size.
378  const learning::ArcAddition& key) {
379  return Size(key.node1()) * HashFuncConst::gold
380  + Size(key.node2()) * HashFuncConst::pi;
381  }
382 
384  INLINE Size HashFunc< learning::ArcAddition >::
385  operator()(const learning::ArcAddition& key) const {
386  return castToSize(key) >> this->_right_shift;
387  }
388 
389 
390  // Returns the value of a key as a Size.
392  const learning::ArcDeletion& key) {
393  return Size(key.node1()) * HashFuncConst::gold
394  + Size(key.node2()) * HashFuncConst::pi;
395  }
396 
398  INLINE Size HashFunc< learning::ArcDeletion >::
399  operator()(const learning::ArcDeletion& key) const {
400  return castToSize(key) >> this->_right_shift;
401  }
402 
403 
404  // Returns the value of a key as a Size.
406  const learning::ArcReversal& key) {
407  return Size(key.node1()) * HashFuncConst::gold
408  + Size(key.node2()) * HashFuncConst::pi;
409  }
410 
412  INLINE Size HashFunc< learning::ArcReversal >::
413  operator()(const learning::ArcReversal& key) const {
414  return castToSize(key) >> this->_right_shift;
415  }
416 
417 
418  // Returns the value of a key as a Size.
420  const learning::EdgeAddition& key) {
421  return Size(key.node1()) * HashFuncConst::gold
422  + Size(key.node2()) * HashFuncConst::pi;
423  }
424 
426  INLINE Size HashFunc< learning::EdgeAddition >::
427  operator()(const learning::EdgeAddition& key) const {
428  return castToSize(key) >> this->_right_shift;
429  }
430 
431 
432  // Returns the value of a key as a Size.
434  const learning::EdgeDeletion& key) {
435  return Size(key.node1()) * HashFuncConst::gold
436  + Size(key.node2()) * HashFuncConst::pi;
437  }
438 
440  INLINE Size HashFunc< learning::EdgeDeletion >::
441  operator()(const learning::EdgeDeletion& key) const {
442  return castToSize(key) >> this->_right_shift;
443  }
444 
445 } /* namespace gum */
446 
447 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
static constexpr Size pi
Definition: hashFunc.h:78
static constexpr Size gold
Definition: hashFunc.h:76
ArcDeletion(NodeId node1, NodeId node2) noexcept
default constructor
static Size castToSize(const learning::EdgeDeletion &key)
Returns the value of a key as a Size.
ArcAddition(NodeId node1, NodeId node2) noexcept
default constructor
~ArcDeletion() noexcept
destructor
~EdgeDeletion() noexcept
destructor
bool operator==(const ArcAddition &from) const noexcept
returns whether two arc additions are identical or not
bool operator==(const ArcDeletion &from) const noexcept
returns whether two arc deletions are identical or not
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
ArcAddition & operator=(const ArcAddition &from) noexcept
copy constructor
NodeId __node2
the second node in the edge or arc to be modified
Definition: graphChange.h:132
~GraphChange() noexcept
destructor
ArcReversal(NodeId node1, NodeId node2) noexcept
default constructor
bool operator==(const EdgeAddition &from) const noexcept
returns whether two edge additions are identical or not
EdgeDeletion & operator=(const EdgeDeletion &from) noexcept
copy constructor
GraphChange & operator=(const GraphChange &from) noexcept
copy constructor
bool operator==(const GraphChange &from) const noexcept
returns whether two graph changes are identical or not
GraphChangeType type() const noexcept
returns the type of the operation
bool operator==(const ArcReversal &from) const noexcept
returns whether two arc reversals are identical or not
GraphChangeType __type
the type of modification
Definition: graphChange.h:126
~ArcAddition() noexcept
destructor
bool operator!=(const ArcReversal &from) const noexcept
returns whether two arc reversals are different or not
ArcReversal & operator=(const ArcReversal &from) noexcept
copy constructor
bool operator==(const EdgeDeletion &from) const noexcept
returns whether two edge deletions are identical or not
NodeId node2() const noexcept
returns the second node involved in the modification
static Size castToSize(const learning::GraphChange &key)
Returns the value of a key as a Size.
EdgeAddition & operator=(const EdgeAddition &from) noexcept
copy constructor
bool operator!=(const EdgeDeletion &from) const noexcept
returns whether two edge deletions are different or not
ArcDeletion & operator=(const ArcDeletion &from) noexcept
copy constructor
NodeId __node1
the first node in the edge or arc to be modified
Definition: graphChange.h:129
bool operator!=(const GraphChange &from) const noexcept
returns whether two graph changes are different or not
GraphChangeType
the type of modification that can be applied to the graph
Definition: graphChange.h:47
bool operator!=(const ArcAddition &from) const noexcept
returns whether two arc additions are different or not
static Size castToSize(const learning::ArcDeletion &key)
Returns the value of a key as a Size.
GraphChange(GraphChangeType type, NodeId node1, NodeId node2) noexcept
default constructor
bool operator!=(const EdgeAddition &from) const noexcept
returns whether two edge additions are different or not
~ArcReversal() noexcept
destructor
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
static Size castToSize(const learning::ArcAddition &key)
Returns the value of a key as a Size.
EdgeAddition(NodeId node1, NodeId node2) noexcept
default constructor
static Size castToSize(const learning::EdgeAddition &key)
Returns the value of a key as a Size.
~EdgeAddition() noexcept
destructor
EdgeDeletion(NodeId node1, NodeId node2) noexcept
default constructor
Size NodeId
Type for node ids.
Definition: graphElements.h:98
static Size castToSize(const learning::ArcReversal &key)
Returns the value of a key as a Size.
NodeId node1() const noexcept
returns the first node involved in the modification
bool operator!=(const ArcDeletion &from) const noexcept
returns whether two arc deletions are different or not