cesarcardinale

M3103 - TP4 - Exo 3

Sep 26th, 2018
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. template<typename T>
  2. void localAdd (const std::shared_ptr<CNode<T>> & ptr, const T &Val){
  3.     if (ptr->GetData () > Val){
  4.         if (ptr->getLC() == nullptr){
  5.             ptr->setLC(std::shared_ptr<CNode <T> > (new CNode<T> (Val)));
  6.             return;
  7.         }
  8.         else localAdd (ptr->getLC(), Val);
  9.     }else{
  10.         if(ptr->getRC() == nullptr){
  11.             ptr->setRC(std::shared_ptr<CNode <T> > (new CNode<T> (Val)));
  12.             return;
  13.         }
  14.         else localAdd (ptr->getRC(), Val);
  15.     }
  16. }
Add Comment
Please, Sign In to add comment