source: git/factory/cf_reval.cc @ 650f2d8

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