Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/06/10 01:56:04 (13 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/MersenneTwister.cs

    r4477 r4722  
    5555
    5656    /// <summary>
     57    /// Used by HeuristicLab.Persistence to initialize new instances during deserialization.
     58    /// </summary>
     59    /// <param name="deserializing">true, if the constructor is called during deserialization.</param>
     60    [StorableConstructor]
     61    private MersenneTwister(bool deserializing) : base(deserializing) { }
     62    /// <summary>
     63    /// Initializes a new instance from an existing one (copy constructor).
     64    /// </summary>
     65    /// <param name="original">The original <see cref="MersenneTwister"/> instance which is used to initialize the new instance.</param>
     66    /// <param name="cloner">A <see cref="Cloner"/> which is used to track all already cloned objects in order to avoid cycles.</param>
     67    private MersenneTwister(MersenneTwister original, Cloner cloner)
     68      : base(original, cloner) {
     69      state = (uint[])original.state.Clone();
     70      p = original.p;
     71      init = original.init;
     72    }
     73    /// <summary>
    5774    /// Initializes a new instance of <see cref="MersenneTwister"/>.
    5875    /// </summary>
     
    7895      init = true;
    7996    }
    80     /// <summary>
    81     /// Used by HeuristicLab.Persistence to initialize new instances during deserialization.
    82     /// </summary>
    83     /// <param name="deserializing">true, if the constructor is called during deserialization.</param>
    84     [StorableConstructor]
    85     private MersenneTwister(bool deserializing) : base(deserializing) { }
    8697
    8798    /// <summary>
     
    91102    /// <returns>The cloned object as <see cref="MersenneTwister"/>.</returns>
    92103    public override IDeepCloneable Clone(Cloner cloner) {
    93       MersenneTwister clone = (MersenneTwister)base.Clone(cloner);
    94       clone.state = (uint[])state.Clone();
    95       clone.p = p;
    96       clone.init = init;
    97       return clone;
     104      return new MersenneTwister(this, cloner);
    98105    }
    99106
Note: See TracChangeset for help on using the changeset viewer.