source: git/factory/cf_reval.cc @ ba5e9e

spielwiese
Last change on this file since ba5e9e was 16f511, checked in by Oleksandr Motsak <motsak@…>, 11 years ago
Fixed the usage of "config.h" (if defined HAVE_CONFIG_H)
  • Property mode set to 100644
File size: 1.2 KB
Line 
1/* emacs edit mode for this file is -*- C++ -*- */
2
3#define MORE_ZEROES
4
5#ifdef HAVE_CONFIG_H
6#include "config.h"
7#endif /* HAVE_CONFIG_H */
8
9#include "cf_assert.h"
10
11#include "cf_defs.h"
12#include "cf_reval.h"
13
14
15REvaluation::REvaluation( const REvaluation & e ):Evaluation()
16{
17    if ( e.gen == 0 )
18        gen = 0;
19    else
20        gen = e.gen->clone();
21    values = e.values;
22}
23
24REvaluation::~REvaluation()
25{
26    if ( gen != 0 )
27        delete gen;
28}
29
30REvaluation&
31REvaluation::operator= ( const REvaluation & e )
32{
33    if ( this != &e ) {
34        if (gen!=0)
35          delete gen;
36        values = e.values;
37        if ( e.gen == 0 )
38            gen = 0;
39        else
40            gen = e.gen->clone();
41    }
42    return *this;
43}
44
45void
46REvaluation::nextpoint()
47{
48    int n = values.max();
49    for ( int i = values.min(); i <= n; i++ )
50        values[i] = gen->generate();
51}
52
53void
54REvaluation::nextpoint (int n)
55{
56  int m= values.max();
57  int t= values.min();
58  for (int i= t; i <= m; i++)
59    values [i]= 0;
60
61  if (m == t)
62  {
63    values [t]= gen->generate();
64    return;
65  }
66  for (int i= 0; i < n; i++)
67  {
68    int l= factoryrandom (m - t + 1) + t;
69    values [l]= gen->generate();
70  }
71}
Note: See TracBrowser for help on using the repository browser.