aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
DFSCode_inl.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright (c) 2005-2021 by Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4  * info_at_agrum_dot_org
5  *
6  * This library is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 
22 /**
23  * @file
24  * @brief Inline implementation of the DFSCode class.
25  *
26  * @author Lionel TORTI and Pierre-Henri WUILLEMIN(@LIP6)
27  */
28 
29 namespace gum {
30  namespace prm {
31  namespace gspan {
32 
33  INLINE
36  ;
37  }
38 
39  INLINE
42 
43  for (const auto code: source.codes)
45  }
46 
47  INLINE
50 
51  for (const auto item: codes)
52  delete item;
53  }
54 
55  INLINE
56  DFSCode& DFSCode::operator=(const DFSCode& source) {
57  for (const auto item: codes)
58  delete item;
59 
60  for (const auto srcitem: source.codes)
62 
63  return *this;
64  }
65 
66  INLINE
67  bool DFSCode::operator==(const DFSCode& from) const {
68  if (codes.size() == from.codes.size()) {
69  for (size_t idx = 0; idx < codes.size(); ++idx) {
70  if ((*codes[idx]) != (*codes[idx])) { return false; }
71  }
72 
73  return true;
74  } else {
75  return false;
76  }
77  }
78 
79  INLINE
80  bool DFSCode::operator!=(const DFSCode& from) const {
81  if (codes.size() == from.codes.size()) {
82  for (size_t idx = 0; idx < codes.size(); ++idx) {
83  if ((*codes[idx]) != (*codes[idx])) { return true; }
84  }
85 
86  return false;
87  } else {
88  return true;
89  }
90  }
91 
92  INLINE
93  bool DFSCode::operator<(const DFSCode& from) const {
96 
97  for (; (iter != codes.end()) && (jter != from.codes.end()); ++iter, ++jter) {
98  if ((**iter) != (**jter)) {
99  EdgeCode& alpha = **iter;
100  EdgeCode& beta = **jter;
101 
102  if (alpha.isBackward()) {
103  if (beta.isForward()) {
104  return true;
105  } else if (alpha.j < beta.j) {
106  // beta is a backward edge
107  return true;
108  } else if ((alpha.j == beta.j) && (alpha.l_ij < beta.l_ij)) {
109  return true;
110  }
111 
112  return false;
113  } else {
114  // alpha is a forward edge
115  if (beta.isBackward()) {
116  return false;
117  } else if (beta.i < alpha.i) {
118  // Beta is a forward edge
119  return true;
120  } else if (beta.i == alpha.i) {
121  if (alpha.l_i < beta.l_i) {
122  return true;
123  } else if (alpha.l_i == beta.l_i) {
124  if (alpha.l_ij < beta.l_ij) {
125  return true;
126  } else if (alpha.l_ij == beta.l_ij) {
127  return alpha.l_j < beta.l_j;
128  }
129  }
130  }
131 
132  return false;
133  }
134 
135  return (**iter) < (**jter);
136  }
137  }
138 
139  return false;
140  }
141 
142  INLINE
143  bool DFSCode::operator<=(const DFSCode& from) const {
146 
147  for (; (iter != codes.end()) && (jter != from.codes.end()); ++iter, ++jter) {
148  if ((**iter) != (**jter)) { return (**iter) < (**jter); }
149  }
150 
151  return codes.size() <= from.codes.size();
152  }
153 
154  } /* namespace gspan */
155  } /* namespace prm */
156 } /* namespace gum */
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
ParamScopeData(const std::string &s, const PRMReferenceSlot< GUM_SCALAR > &ref, Idx d)
INLINE std::ostream & operator<<(std::ostream &out, const EdgeData< GUM_SCALAR > &data)
Print a EdgeData<GUM_SCALAR> in out.