View difference between Paste ID: ijtTBbMU and qJ2HnFTZ
SHOW: | | - or go back to the newest paste.
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;
25+
		mygen gen(treshmin, treshmax);
26-
		static std::mt19937 engine(rd());
26+
27
                double curThreshold = gen();
28-
                double curThreshold = randomDoubleEngine(engine, treshmin, treshmax );
28+
29
         }
30
31
//file: utilities.h
32
struct mygen
33-
template <typename Generator>
33+
34-
double randomDoubleEngine(Generator& engine, double low_bound, double high_bound )
34+
    mygen(double low, double high) : dist(low, high) {}
35
    double operator()() { return dist(eng); }
36-
	if (low_bound > high_bound){
36+
  private:
37-
		std::swap(low_bound, high_bound);
37+
38-
	}
38+
    std::mt19937 engine;
39
    std::uniform_real_distribution<> dist;
40-
	return std::uniform_real_distribution<>( low_bound, high_bound )( engine );
40+