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/OnlineMeanAbsoluteErrorCalculator.cs

    r14185 r14293  
    2222using System;
    2323using System.Collections.Generic;
     24using HeuristicLab.Common;
    2425
    2526namespace HeuristicLab.Problems.DataAnalysis {
    26   public class OnlineMeanAbsoluteErrorCalculator : IOnlineCalculator {
     27  public class OnlineMeanAbsoluteErrorCalculator : IOnlineCalculator, IDeepCloneable {
    2728
    2829    private double sae;
     
    3637    public OnlineMeanAbsoluteErrorCalculator() {
    3738      Reset();
     39    }
     40
     41    private OnlineMeanAbsoluteErrorCalculator(OnlineMeanAbsoluteErrorCalculator other) {
     42      sae = other.sae;
     43      n = other.n;
     44      errorState = other.errorState;
    3845    }
    3946
     
    8794      }
    8895    }
     96
     97    // IDeepCloneable interface members
     98    public object Clone() {
     99      return new OnlineMeanAbsoluteErrorCalculator(this);
     100    }
     101
     102    public IDeepCloneable Clone(Cloner cloner) {
     103      var clone = cloner.GetClone(this);
     104      if (clone == null) {
     105        clone = (IDeepCloneable)this.Clone();
     106        cloner.RegisterClonedObject(this, clone);
     107      }
     108      return clone;
     109    }
    89110  }
    90111}
Note: See TracChangeset for help on using the changeset viewer.