Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/20/16 15:51:04 (8 years ago)
Author:
bburlacu
Message:

#2672: Implement online calculator cloning.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineMeanErrorCalculator.cs

    r14185 r14293  
    2222using System;
    2323using System.Collections.Generic;
     24using HeuristicLab.Common;
    2425
    2526namespace HeuristicLab.Problems.DataAnalysis {
    26   public class OnlineMeanErrorCalculator : IOnlineCalculator {
     27  public class OnlineMeanErrorCalculator : IOnlineCalculator, IDeepCloneable {
    2728
    2829    private readonly OnlineMeanAndVarianceCalculator meanAndVarianceCalculator;
     
    3435      meanAndVarianceCalculator = new OnlineMeanAndVarianceCalculator();
    3536      Reset();
     37    }
     38
     39    private OnlineMeanErrorCalculator(OnlineMeanAndVarianceCalculator meanAndVarianceCalculator) {
     40      this.meanAndVarianceCalculator = meanAndVarianceCalculator;
    3641    }
    3742
     
    7479      }
    7580    }
     81
     82    // IDeepCloneable members
     83    public object Clone() {
     84      var meanAndVarianceCalculatorClone = (OnlineMeanAndVarianceCalculator)meanAndVarianceCalculator.Clone();
     85      return new OnlineMeanErrorCalculator(meanAndVarianceCalculatorClone);
     86    }
     87
     88    public IDeepCloneable Clone(Cloner cloner) {
     89      var clone = cloner.GetClone(this);
     90      if (clone == null) {
     91        var meanAndVarianceCalculatorClone = (OnlineMeanAndVarianceCalculator)meanAndVarianceCalculator.Clone(cloner);
     92        clone = new OnlineMeanErrorCalculator(meanAndVarianceCalculatorClone);
     93        cloner.RegisterClonedObject(this, clone);
     94      }
     95      return clone;
     96    }
    7697  }
    7798}
Note: See TracChangeset for help on using the changeset viewer.