Advertisement
Guest User

Untitled

a guest
Apr 6th, 2012
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.10 KB | None | 0 0
  1. //file: myclass.h
  2.        status myclass::doThat(param1, param2){
  3.            
  4.           bool cond = shouldIStop(param1, param2, param3, param4);
  5.           status myStatus = NOTLEAF;
  6.           if(!cond){
  7.               ...
  8.               doSomething(param3, param4);
  9.               ...
  10.               ...
  11.               ...
  12.               doThat(param1, param2, param3, param4);
  13.           }
  14.           else{
  15.               ...
  16.               ...
  17.               myStatus = LEAF;
  18.               ...
  19.           }
  20.           return (myStatus);
  21.         }
  22.  
  23.     void myclass::doSomething(double treshmin, double treshmax)
  24.     {
  25.         std::random_device rd;
  26.         static std::mt19937 engine(rd());
  27.                 .....
  28.                 double curThreshold = randomDoubleEngine(engine, treshmin, treshmax );
  29.                 ...
  30.          }
  31.  
  32. //file: utilities.h
  33. template <typename Generator>
  34. double randomDoubleEngine(Generator& engine, double low_bound, double high_bound )
  35. {
  36.     if (low_bound > high_bound){
  37.         std::swap(low_bound, high_bound);
  38.     }
  39.  
  40.     return std::uniform_real_distribution<>( low_bound, high_bound )( engine );
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement