1 #ifndef BASIC_DDTREE_HH 2 #define BASIC_DDTREE_HH 17 if(0 == a && 0==b)
return false;
18 if(0 == a && 0!=b)
return true;
19 if(0 !=a && 0==b)
return false;
20 return a->getVal() < b->getVal();
28 if(0 == a && 0==b)
return true;
29 if(0 == a && 0!=b)
return false;
30 if(0 !=a && 0==b)
return false;
31 return a->getVal() == b->getVal();
36 template<
typename ValueType>
40 typename std::vector< MINT::counted_ptr< DDTree<ValueType> > >
daughters;
62 for(
unsigned int i=0; i<
daughters.size(); i++){
83 sortDaughtersBy<SORTERTYPE>();
84 for(
unsigned int i=0; i<
daughters.size(); i++){
85 daughters[i]->template sortDaughtersBy<SORTERTYPE>();
90 return sortDaughtersBy<lessByPointedTo< MINT::counted_ptr<DDTree<ValueType> > > >();
115 if(i < 0 || i >=
nDgtr()){
121 if(i < 0 || i >=
nDgtr()){
157 template<
typename COMPATIBLE_TYPE>
168 for(
unsigned int i=0; i <
daughters.size(); i++){
169 top->setDgtr(i,
daughters[i]->
template CloneVariableType<COMPATIBLE_TYPE>(top.
get()));
175 return CloneVariableType<ValueType>(parent);
178 template<
typename COMPATIBLE_ITEM>
183 for(
int i=0; i < other.
nDgtr(); i++){
194 template<
typename COMPATIBLE_ITEM>
204 template<
typename COMPATIBLE_ITEM>
224 addDgtr(
const ValueType& pdg_id1,
const ValueType& pdg_id2){
230 ,
const ValueType& pdg_id2
231 ,
const ValueType& pdg_id3
238 ,
const ValueType& pdg_id2
239 ,
const ValueType& pdg_id3
240 ,
const ValueType& pdg_id4
248 for(
int i=0; i<n; i++){
253 for(
int i=0; i<n; i++){
270 std::vector<MINT::const_counted_ptr<DDTree<ValueType> > >
273 std::vector<MINT::const_counted_ptr< DDTree<ValueType> > > sistersTree;
278 sistersTree.push_back(
_parentPtr->daughters[i]);
285 if(!
nDgtr())
return 1;
286 for(
int i=0; i<
nDgtr(); i++){
288 if(n > nMax) nMax = n;
294 std::vector<const ValueType*> listOfStableDaughters;
296 return listOfStableDaughters;
299 std::vector<ValueType*> listOfStableDaughters;
301 return listOfStableDaughters;
306 listOfStableDaughtersPtr(
new std::vector<const ValueType*> );
308 return listOfStableDaughtersPtr;
312 listOfStableDaughtersPtr(
new std::vector<ValueType*> );
314 return listOfStableDaughtersPtr;
316 void finalState(std::vector<const ValueType*>& theList)
const{
320 for(
int i=0; i<
nDgtr(); i++){
329 for(
int i=0; i<
nDgtr(); i++){
335 template<
typename COMPARABLE_CLASS>
336 std::vector<ValueType*>
338 std::vector<ValueType*> stableDaughters =
finalState();
340 std::vector<ValueType*> sorted;
342 if(stableDaughters.size() != pattern.size()){
346 for(
unsigned int i=0; i<pattern.size(); i++){
347 for(
typename std::vector<ValueType*>::iterator jt = stableDaughters.begin();
348 jt != stableDaughters.end();
350 if( *(*jt) == pattern[i] ){
351 sorted.push_back(*jt);
352 stableDaughters.erase(jt);
360 void print(std::ostream& os = std::cout
361 , std::string indentString=
"" 365 for(
int i=0; i<
nDgtr(); i++){
367 os << indentString +
" '--";
368 daughters[i]->print(os, indentString +
" ");
370 os << indentString +
" |--";
371 daughters[i]->print(os, indentString +
" | ");
376 ,
int generation=0)
const{
378 if(
nDgtr() <= 0)
return;
379 if(generation > 0) seam <<
"(";
381 for(
int i=0; i<
nDgtr(); i++){
382 daughters[i]->oneLiner(seam, generation + 1);
383 if(i <
nDgtr()-1) seam <<
",";
385 if(generation > 0) seam <<
")";
388 std::stringstream seam;
400 template <
typename ValueType>
407 template <
typename ValueType>
DDTree(const ValueType &val, const DDTree< ValueType > *parent)
std::vector< MINT::const_counted_ptr< DDTree< ValueType > > > getSistersTrees() const
DDTree(const DDTree< ValueType > &other)
MINT::counted_ptr< std::vector< const ValueType * > > finalStatePtr() const
DDTree(const DDTree< COMPATIBLE_ITEM > &other)
MINT::counted_ptr< DDTree< ValueType > > addDgtr(const DDTree< ValueType > *treePtr)
MINT::counted_ptr< DDTree< ValueType > > addDgtr(const ValueType &pdg_id1, const ValueType &pdg_id2, const ValueType &pdg_id3)
void oneLiner(std::string &ring) const
DDTree(const ValueType &pdg_id)
DDTree< ValueType > operator=(const DDTree< COMPATIBLE_ITEM > &other)
bool operator()(const T a, const T b)
void finalState(std::vector< const ValueType * > &theList) const
void addDgtrArray(DDTree< ValueType > *treePtr[], int n)
MINT::counted_ptr< std::vector< ValueType * > > finalStatePtr()
std::vector< MINT::counted_ptr< DDTree< ValueType > > > daughters
void addDgtrArray(ValueType pdg_id[], int n)
const ValueType & getVal() const
void setParent(const DDTree< ValueType > *parent=0)
void print(std::ostream &os=std::cout, std::string indentString="") const
bool isFinalState() const
void setVal(const ValueType &m)
DDTree< ValueType > operator=(const DDTree< ValueType > &other)
MINT::counted_ptr< DDTree< ValueType > > addDgtr(const ValueType &pdg_id1, const ValueType &pdg_id2, const ValueType &pdg_id3, const ValueType &pdg_id4)
MINT::counted_ptr< DDTree< ValueType > > Clone(DDTree< ValueType > *parent=0) const
void setDgtr(unsigned int i, const MINT::counted_ptr< DDTree< ValueType > > &tr)
MINT::const_counted_ptr< DDTree< ValueType > > getDgtrTreePtr(int i) const
MINT::counted_ptr< DDTree< ValueType > > addDgtr(const ValueType &pdg_id)
void disconnectAllDaughters()
void Copy(const DDTree< COMPATIBLE_ITEM > &other)
const DDTree< ValueType > * _parentPtr
DDTree(const DDTree< ValueType > *parent)
bool operator()(const T a, const T b)
MINT::counted_ptr< DDTree< ValueType > > addDgtr(const ValueType &pdg_id1, const ValueType &pdg_id2)
std::vector< ValueType * > finalStateInThisOrder(const std::vector< COMPARABLE_CLASS > &pattern)
std::vector< const ValueType * > finalState() const
std::ostream & operator<<(std::ostream &os, const DDTree< ValueType > &theTree)
void oneLiner(std::stringstream &seam, int generation=0) const
MINT::counted_ptr< DDTree< ValueType > > getDgtrTreePtr(int i)
std::string oneLiner() const
const DDTree< ValueType > * getParent() const
MINT::counted_ptr< DDTree< COMPATIBLE_TYPE > > CloneVariableType(DDTree< COMPATIBLE_TYPE > *parent=0) const
void finalState(std::vector< ValueType * > &theList)
std::vector< ValueType * > finalState()
const ValueType & getDgtrVal(int i) const
ValueType & getDgtrVal(int i)