aGrUM  0.14.2
graphChange_inl.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
28 #ifndef DOXYGEN_SHOULD_SKIP_THIS
29 
30 namespace gum {
31 
32  namespace learning {
33 
36  NodeId node1,
37  NodeId node2) noexcept :
38  __type{type},
39  __node1{node1}, __node2{node2} {
40  GUM_CONSTRUCTOR(GraphChange);
41  }
42 
44  INLINE GraphChange::GraphChange(const GraphChange& from) noexcept :
45  __type{from.__type}, __node1{from.__node1}, __node2{from.__node2} {
46  GUM_CONS_CPY(GraphChange);
47  }
48 
50  INLINE GraphChange::GraphChange(GraphChange&& from) noexcept :
51  __type{from.__type}, __node1{from.__node1}, __node2{from.__node2} {
52  GUM_CONS_MOV(GraphChange);
53  }
54 
56  INLINE GraphChange::~GraphChange() noexcept { GUM_DESTRUCTOR(GraphChange); }
57 
59  INLINE GraphChange& GraphChange::operator=(const GraphChange& from) noexcept {
60  __type = from.__type;
61  __node1 = from.__node1;
62  __node2 = from.__node2;
63  return *this;
64  }
65 
67  INLINE GraphChange& GraphChange::operator=(GraphChange&& from) noexcept {
68  __type = from.__type;
69  __node1 = from.__node1;
70  __node2 = from.__node2;
71  return *this;
72  }
73 
75  INLINE GraphChangeType GraphChange::type() const noexcept { return __type; }
76 
78  INLINE NodeId GraphChange::node1() const noexcept { return __node1; }
79 
81  INLINE NodeId GraphChange::node2() const noexcept { return __node2; }
82 
84  INLINE bool GraphChange::operator==(const GraphChange& from) const noexcept {
85  return ((__node1 == from.__node1) && (__node2 == from.__node2)
86  && (__type == from.__type));
87  }
88 
90  INLINE bool GraphChange::operator!=(const GraphChange& from) const noexcept {
91  return !operator==(from);
92  }
93 
94  // ===========================================================================
95 
99  // do not use GUM_CONSTRUCTOR here because, to speed up GraphChange's
100  // destructor, we did not make the latter's destructor virtual.
101  }
102 
104  INLINE ArcAddition::ArcAddition(const ArcAddition& from) noexcept :
105  GraphChange(from) {
106  // do not use GUM_CONS_CPY here because, to speed up GraphChange's
107  // destructor, we did not make the latter's destructor virtual.
108  }
109 
111  INLINE ArcAddition::ArcAddition(ArcAddition&& from) noexcept :
112  GraphChange(std::move(from)) {
113  // do not use GUM_CONS_MOV here because, to speed up GraphChange's
114  // destructor, we did not make the latter's destructor virtual.
115  }
116 
118  INLINE ArcAddition::~ArcAddition() noexcept {
119  // do not use GUM_DESTRUCTOR here because, to speed up GraphChange's
120  // destructor, we did not make the latter's destructor virtual.
121  }
122 
124  INLINE ArcAddition& ArcAddition::operator=(const ArcAddition& from) noexcept {
126  return *this;
127  }
128 
130  INLINE ArcAddition& ArcAddition::operator=(ArcAddition&& from) noexcept {
131  GraphChange::operator=(std::move(from));
132  return *this;
133  }
134 
136  INLINE bool ArcAddition::operator==(const ArcAddition& from) const noexcept {
137  return ((node1() == from.node1()) && (node2() == from.node2()));
138  }
139 
141  INLINE bool ArcAddition::operator!=(const ArcAddition& from) const noexcept {
142  return !operator==(from);
143  }
144 
145  // ===========================================================================
146 
148  INLINE ArcDeletion::ArcDeletion(NodeId node1, NodeId node2) noexcept :
150  // do not use GUM_CONSTRUCTOR here because, to speed up GraphChange's
151  // destructor, we did not make the latter's destructor virtual.
152  }
153 
155  INLINE ArcDeletion::ArcDeletion(const ArcDeletion& from) noexcept :
156  GraphChange(from) {
157  // do not use GUM_CONS_CPY here because, to speed up GraphChange's
158  // destructor, we did not make the latter's destructor virtual.
159  }
160 
162  INLINE ArcDeletion::ArcDeletion(ArcDeletion&& from) noexcept :
163  GraphChange(std::move(from)) {
164  // do not use GUM_CONS_MOV here because, to speed up GraphChange's
165  // destructor, we did not make the latter's destructor virtual.
166  }
167 
169  INLINE ArcDeletion::~ArcDeletion() noexcept {
170  // do not use GUM_DESTRUCTOR here because, to speed up GraphChange's
171  // destructor, we did not make the latter's destructor virtual.
172  }
173 
175  INLINE ArcDeletion& ArcDeletion::operator=(const ArcDeletion& from) noexcept {
177  return *this;
178  }
179 
181  INLINE ArcDeletion& ArcDeletion::operator=(ArcDeletion&& from) noexcept {
182  GraphChange::operator=(std::move(from));
183  return *this;
184  }
185 
187  INLINE bool ArcDeletion::operator==(const ArcDeletion& from) const noexcept {
188  return ((node1() == from.node1()) && (node2() == from.node2()));
189  }
190 
192  INLINE bool ArcDeletion::operator!=(const ArcDeletion& from) const noexcept {
193  return !operator==(from);
194  }
195 
196  // ===========================================================================
197 
199  INLINE ArcReversal::ArcReversal(NodeId node1, NodeId node2) noexcept :
201  // do not use GUM_CONSTRUCTOR here because, to speed up GraphChange's
202  // destructor, we did not make the latter's destructor virtual.
203  }
204 
206  INLINE ArcReversal::ArcReversal(const ArcReversal& from) noexcept :
207  GraphChange(from) {
208  // do not use GUM_CONS_CPY here because, to speed up GraphChange's
209  // destructor, we did not make the latter's destructor virtual.
210  }
211 
213  INLINE ArcReversal::ArcReversal(ArcReversal&& from) noexcept :
214  GraphChange(std::move(from)) {
215  // do not use GUM_CONS_MOV here because, to speed up GraphChange's
216  // destructor, we did not make the latter's destructor virtual.
217  }
218 
220  INLINE ArcReversal::~ArcReversal() noexcept {
221  // do not use GUM_DESTRUCTOR here because, to speed up GraphChange's
222  // destructor, we did not make the latter's destructor virtual.
223  }
224 
226  INLINE ArcReversal& ArcReversal::operator=(const ArcReversal& from) noexcept {
228  return *this;
229  }
230 
232  INLINE ArcReversal& ArcReversal::operator=(ArcReversal&& from) noexcept {
233  GraphChange::operator=(std::move(from));
234  return *this;
235  }
236 
238  INLINE bool ArcReversal::operator==(const ArcReversal& from) const noexcept {
239  return ((node1() == from.node1()) && (node2() == from.node2()));
240  }
241 
243  INLINE bool ArcReversal::operator!=(const ArcReversal& from) const noexcept {
244  return !operator==(from);
245  }
246 
247  // ===========================================================================
248 
252  // do not use GUM_CONSTRUCTOR here because, to speed up GraphChange's
253  // destructor, we did not make the latter's destructor virtual.
254  }
255 
257  INLINE EdgeAddition::EdgeAddition(const EdgeAddition& from) noexcept :
258  GraphChange(from) {
259  // do not use GUM_CONS_CPY here because, to speed up GraphChange's
260  // destructor, we did not make the latter's destructor virtual.
261  }
262 
264  INLINE EdgeAddition::EdgeAddition(EdgeAddition&& from) noexcept :
265  GraphChange(std::move(from)) {
266  // do not use GUM_CONS_MOV here because, to speed up GraphChange's
267  // destructor, we did not make the latter's destructor virtual.
268  }
269 
271  INLINE EdgeAddition::~EdgeAddition() noexcept {
272  // do not use GUM_DESTRUCTOR here because, to speed up GraphChange's
273  // destructor, we did not make the latter's destructor virtual.
274  }
275 
277  INLINE EdgeAddition& EdgeAddition::
278  operator=(const EdgeAddition& from) noexcept {
280  return *this;
281  }
282 
284  INLINE EdgeAddition& EdgeAddition::operator=(EdgeAddition&& from) noexcept {
285  GraphChange::operator=(std::move(from));
286  return *this;
287  }
288 
290  INLINE bool EdgeAddition::operator==(const EdgeAddition& from) const noexcept {
291  return (((node1() == from.node1()) && (node2() == from.node2()))
292  || ((node1() == from.node2()) && (node2() == from.node1())));
293  }
294 
296  INLINE bool EdgeAddition::operator!=(const EdgeAddition& from) const noexcept {
297  return !operator==(from);
298  }
299 
300  // ===========================================================================
301 
305  // do not use GUM_CONSTRUCTOR here because, to speed up GraphChange's
306  // destructor, we did not make the latter's destructor virtual.
307  }
308 
310  INLINE EdgeDeletion::EdgeDeletion(const EdgeDeletion& from) noexcept :
311  GraphChange(from) {
312  // do not use GUM_CONS_CPY here because, to speed up GraphChange's
313  // destructor, we did not make the latter's destructor virtual.
314  }
315 
317  INLINE EdgeDeletion::EdgeDeletion(EdgeDeletion&& from) noexcept :
318  GraphChange(std::move(from)) {
319  // do not use GUM_CONS_MOV here because, to speed up GraphChange's
320  // destructor, we did not make the latter's destructor virtual.
321  }
322 
324  INLINE EdgeDeletion::~EdgeDeletion() noexcept {
325  // do not use GUM_DESTRUCTOR here because, to speed up GraphChange's
326  // destructor, we did not make the latter's destructor virtual.
327  }
328 
330  INLINE EdgeDeletion& EdgeDeletion::
331  operator=(const EdgeDeletion& from) noexcept {
333  return *this;
334  }
335 
337  INLINE EdgeDeletion& EdgeDeletion::operator=(EdgeDeletion&& from) noexcept {
338  GraphChange::operator=(std::move(from));
339  return *this;
340  }
341 
343  INLINE bool EdgeDeletion::operator==(const EdgeDeletion& from) const noexcept {
344  return (((node1() == from.node1()) && (node2() == from.node2()))
345  || ((node1() == from.node2()) && (node2() == from.node1())));
346  }
347 
349  INLINE bool EdgeDeletion::operator!=(const EdgeDeletion& from) const noexcept {
350  return !operator==(from);
351  }
352 
353 
354  } /* namespace learning */
355 
356 
357  // ===========================================================================
358 
359  // Returns the value of a key as a Size.
361  const learning::GraphChange& key) {
362  return Size(key.node1()) * HashFuncConst::gold
363  + Size(key.node2()) * HashFuncConst::pi;
364  }
365 
367  INLINE Size HashFunc< learning::GraphChange >::
368  operator()(const learning::GraphChange& key) const {
369  return castToSize(key) >> this->_right_shift;
370  }
371 
372 
373  // Returns the value of a key as a Size.
375  const learning::ArcAddition& key) {
376  return Size(key.node1()) * HashFuncConst::gold
377  + Size(key.node2()) * HashFuncConst::pi;
378  }
379 
381  INLINE Size HashFunc< learning::ArcAddition >::
382  operator()(const learning::ArcAddition& key) const {
383  return castToSize(key) >> this->_right_shift;
384  }
385 
386 
387  // Returns the value of a key as a Size.
389  const learning::ArcDeletion& key) {
390  return Size(key.node1()) * HashFuncConst::gold
391  + Size(key.node2()) * HashFuncConst::pi;
392  }
393 
395  INLINE Size HashFunc< learning::ArcDeletion >::
396  operator()(const learning::ArcDeletion& key) const {
397  return castToSize(key) >> this->_right_shift;
398  }
399 
400 
401  // Returns the value of a key as a Size.
403  const learning::ArcReversal& key) {
404  return Size(key.node1()) * HashFuncConst::gold
405  + Size(key.node2()) * HashFuncConst::pi;
406  }
407 
409  INLINE Size HashFunc< learning::ArcReversal >::
410  operator()(const learning::ArcReversal& key) const {
411  return castToSize(key) >> this->_right_shift;
412  }
413 
414 
415  // Returns the value of a key as a Size.
417  const learning::EdgeAddition& key) {
418  return Size(key.node1()) * HashFuncConst::gold
419  + Size(key.node2()) * HashFuncConst::pi;
420  }
421 
423  INLINE Size HashFunc< learning::EdgeAddition >::
424  operator()(const learning::EdgeAddition& key) const {
425  return castToSize(key) >> this->_right_shift;
426  }
427 
428 
429  // Returns the value of a key as a Size.
431  const learning::EdgeDeletion& key) {
432  return Size(key.node1()) * HashFuncConst::gold
433  + Size(key.node2()) * HashFuncConst::pi;
434  }
435 
437  INLINE Size HashFunc< learning::EdgeDeletion >::
438  operator()(const learning::EdgeDeletion& key) const {
439  return castToSize(key) >> this->_right_shift;
440  }
441 
442 } /* namespace gum */
443 
444 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
static constexpr Size pi
Definition: hashFunc.h:76
static constexpr Size gold
Definition: hashFunc.h:74
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
gum is the global namespace for all aGrUM entities
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:129
~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:123
~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:126
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:44
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:45
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:97
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