00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #if defined(AMBIGUOUS_STRING_FUNCTIONS_BUG)
00045 #include <string>
00046 #endif
00047 #include <iostream>
00048
00049 #if defined(STL_TEMPLATE_DEFAULT_PARAMS_FIRST_BUG)
00050 #include <vector>
00051 #include <algorithm>
00052 #endif
00053
00054
00055
00056
00057 #include "Lattice/LatticeNode.h"
00058
00059
00060
00061
00062 #include <vector>
00063 #include <algorithm>
00064
00065
00066
00067
00068 const char* const kLLLNString = "Lattice.LatticeLeftNode";
00069 const char* const kLLRNString = "Lattice.LatticeRightNode";
00070
00071
00072
00073
00074
00075
00076
00077 LatticeLeftNode::
00078 LatticeLeftNode(const LatticeDef::StoreType& data)
00079 : m_Links (*new Links),
00080 m_VLeftID (*new VectorLeftID),
00081 m_VRightID(*new VectorRightID),
00082 m_ID (data.identifier())
00083 {
00084 }
00085
00086 LatticeLeftNode::
00087 LatticeLeftNode(LeftID id)
00088 : m_Links (*new Links),
00089 m_VLeftID (*new VectorLeftID),
00090 m_VRightID(*new VectorRightID),
00091 m_ID (id)
00092 {
00093 }
00094
00095 LatticeLeftNode::
00096 ~LatticeLeftNode()
00097 {
00098 delete &m_Links;
00099 delete &m_VLeftID;
00100 delete &m_VRightID;
00101 }
00102
00103
00104
00105
00106 LatticeRightNode::
00107 LatticeRightNode(const LatticeDef::StoreType& data)
00108 : m_Links (*new Links),
00109 m_VRightID(*new VectorRightID),
00110 m_VLeftID (*new VectorLeftID),
00111 m_ID (data.identifier())
00112 {
00113 }
00114
00115 LatticeRightNode::
00116 LatticeRightNode(RightID id)
00117 : m_Links (*new Links),
00118 m_VRightID(*new VectorRightID),
00119 m_VLeftID (*new VectorLeftID),
00120 m_ID (id)
00121 {
00122 }
00123
00124 LatticeRightNode::
00125 ~LatticeRightNode()
00126 { delete &m_Links;
00127 delete &m_VLeftID;
00128 delete &m_VRightID;
00129 }
00130
00131
00132
00133
00134 void
00135 LatticeLeftNode::
00136 show(ostream& os) const
00137 {
00138 os << " Left data ID " << identifier() << ":"
00139 << endl
00140 << " has " << links().size() << " links,"
00141 << endl
00142 << " connecting it to " << m_VRightID.size() << " right data: ";
00143
00144
00145 typedef LatticeLeftNode::RightItr Ritr;
00146 Ritr i = m_VRightID.begin();
00147 Ritr iEnd = m_VRightID.end();
00148 for ( ; i != iEnd; ++i)
00149 {
00150 os << " " << *i;
00151 }
00152 os << endl
00153 << " and shared with " << m_VLeftID.size() << " left data:";
00154
00155
00156 typedef LatticeLeftNode::LeftItr Litr;
00157 Litr j = m_VLeftID.begin();
00158 Litr jEnd = m_VLeftID.end();
00159 for ( ; j != jEnd; ++j)
00160 {
00161 os << " " << *j;
00162 }
00163 os << endl;
00164 }
00165
00166 void
00167 LatticeRightNode::
00168 show(ostream& os) const
00169 {
00170 os << " Right data ID " << identifier() << ":"
00171 << endl
00172 << " has " << links().size() << " links,"
00173 << endl
00174 << " connecting it to " << m_VLeftID.size() << " left data: ";
00175
00176
00177 typedef LatticeRightNode::LeftItr Litr;
00178 Litr m = m_VLeftID.begin();
00179 Litr mEnd = m_VLeftID.end();
00180 for ( ; m != mEnd; ++m)
00181 {
00182 os << " " << *m;
00183 }
00184 os << endl
00185 << " and shared with " << m_VRightID.size() << " right data:";
00186
00187 typedef LatticeRightNode::RightItr Ritr;
00188 Ritr n = m_VRightID.begin();
00189 Ritr nEnd = m_VRightID.end();
00190 for ( ; n != nEnd; ++n)
00191 {
00192 os << " " << *n;
00193 }
00194 os << endl;
00195 }
00196
00197
00198
00199
00200
00201
00202
00203
00204 const LatticeLeftNode::
00205 Links&
00206 LatticeLeftNode ::
00207 links() const
00208 {
00209 return m_Links;
00210 }
00211
00212
00213 Bool_t
00214 LatticeLeftNode::
00215 isLinkedTo(RightID id) const
00216 {
00217 return (find(m_VRightID.begin(),m_VRightID.end(),id) == m_VRightID.end()) ?
00218 0 : 1;
00219 }
00220
00221
00222 Bool_t
00223 LatticeLeftNode::
00224 sharesLinksWith(LeftID id) const
00225 {
00226 return (find(m_VLeftID.begin(),m_VLeftID.end(),id) == m_VLeftID.end()) ?
00227 0 : 1;
00228 }
00229
00230
00231 LatticeLeftNode::LeftID
00232 LatticeLeftNode::
00233 identifier() const
00234 {
00235 return m_ID;
00236 }
00237
00238
00239
00240
00241
00242 const LatticeRightNode::
00243 Links&
00244 LatticeRightNode ::
00245 links() const
00246 {
00247 return m_Links;
00248 }
00249
00250
00251 Bool_t
00252 LatticeRightNode::
00253 isLinkedTo(LeftID id) const
00254 {
00255 return (find(m_VLeftID.begin(),m_VLeftID.end(),id) == m_VLeftID.end()) ?
00256 0 : 1;
00257 }
00258
00259
00260 Bool_t
00261 LatticeRightNode::
00262 sharesLinksWith(RightID id) const
00263 {
00264 return (find(m_VRightID.begin(),m_VRightID.end(),id) == m_VRightID.end()) ?
00265 0 : 1;
00266 }
00267
00268
00269 LatticeRightNode::RightID
00270 LatticeRightNode::
00271 identifier() const
00272 {
00273 return m_ID;
00274 }