Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/06/10 01:56:04 (14 years ago)
Author:
swagner
Message:

Merged cloning refactoring branch back into trunk (#922)

Location:
trunk/sources
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources

  • trunk/sources/HeuristicLab.Random/3.3/NormalDistributedRandom.cs

    r4477 r4722  
    450450
    451451    /// <summary>
     452    /// Used by HeuristicLab.Persistence to initialize new instances during deserialization.
     453    /// </summary>
     454    /// <param name="deserializing">true, if the constructor is called during deserialization.</param>
     455    [StorableConstructor]
     456    private NormalDistributedRandom(bool deserializing) : base(deserializing) { }
     457
     458    /// <summary>
     459    /// Initializes a new instance from an existing one (copy constructor).
     460    /// </summary>
     461    /// <param name="original">The original <see cref="NormalDistributedRandom"/> instance which is used to initialize the new instance.</param>
     462    /// <param name="cloner">A <see cref="Cloner"/> which is used to track all already cloned objects in order to avoid cycles.</param>
     463    private NormalDistributedRandom(NormalDistributedRandom original, Cloner cloner)
     464      : base(original, cloner) {
     465      uniform = cloner.Clone(original.uniform);
     466      mu = original.mu;
     467      sigma = original.sigma;
     468    }
     469
     470    /// <summary>
    452471    /// Initializes a new instance of <see cref="NormalDistributedRandom"/> with µ = 0 and sigma = 1
    453472    /// and a new random number generator.
     
    471490      this.uniform = uniformRandom;
    472491    }
    473     /// <summary>
    474     /// Used by HeuristicLab.Persistence to initialize new instances during deserialization.
    475     /// </summary>
    476     /// <param name="deserializing">true, if the constructor is called during deserialization.</param>
    477     [StorableConstructor]
    478     private NormalDistributedRandom(bool deserializing) : base(deserializing) { }
    479492
    480493    #region IRandom Members
     
    529542    /// <returns>The cloned object as <see cref="NormalDistributedRandom"/>.</returns>
    530543    public override IDeepCloneable Clone(Cloner cloner) {
    531       NormalDistributedRandom clone = (NormalDistributedRandom)base.Clone(cloner);
    532       clone.uniform = (IRandom)cloner.Clone(uniform);
    533       clone.mu = mu;
    534       clone.sigma = sigma;
    535       return clone;
     544      return new NormalDistributedRandom(this, cloner);
    536545    }
    537546
Note: See TracChangeset for help on using the changeset viewer.