Changeset 563


Ignore:
Timestamp:
11/14/2008 9:05:23 AM (6 years ago)
Author:
lowjoel
Message:

Remove the inheritance from Random, PRNG is separate.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/Manager/PRNG.cs

    r549 r563  
    4040    /// random data erase passes. 
    4141    /// </summary> 
    42     public abstract class PRNG : Random 
     42    public abstract class PRNG 
    4343    { 
    4444        public override string ToString() 
     
    7474 
    7575        #region Random members 
    76         public override int Next(int maxValue) 
     76        /// <summary> 
     77        /// Returns a nonnegative random number less than the specified maximum. 
     78        /// </summary> 
     79        /// <param name="maxValue">The exclusive upper bound of the random number 
     80        /// to be generated. maxValue must be greater than or equal to zero.</param> 
     81        /// <returns>A 32-bit signed integer greater than or equal to zero, and 
     82        /// less than maxValue; that is, the range of return values ordinarily 
     83        /// includes zero but not maxValue. However, if maxValue equals zero, 
     84        /// maxValue is returned.</returns> 
     85        public int Next(int maxValue) 
    7786        { 
    7887            if (maxValue == 0) 
     
    8190        } 
    8291 
    83         public override int Next(int minValue, int maxValue) 
     92        /// <summary> 
     93        /// Returns a random number within a specified range. 
     94        /// </summary> 
     95        /// <param name="minValue">The inclusive lower bound of the random number 
     96        /// returned.</param> 
     97        /// <param name="maxValue">The exclusive upper bound of the random number 
     98        /// returned. maxValue must be greater than or equal to minValue.</param> 
     99        /// <returns>A 32-bit signed integer greater than or equal to minValue and 
     100        /// less than maxValue; that is, the range of return values includes minValue 
     101        /// but not maxValue. If minValue equals maxValue, minValue is returned.</returns> 
     102        public int Next(int minValue, int maxValue) 
    84103        { 
    85104            if (minValue > maxValue) 
     
    90109        } 
    91110 
    92         public unsafe override int Next() 
     111        /// <summary> 
     112        /// Returns a nonnegative random number. 
     113        /// </summary> 
     114        /// <returns>A 32-bit signed integer greater than or equal to zero and less 
     115        /// than System.Int32.MaxValue.</returns> 
     116        public unsafe int Next() 
    93117        { 
    94118            //Declare a return variable 
     
    112136        } 
    113137 
    114         protected unsafe override double Sample() 
    115         { 
    116             //Declare a return variable 
    117             double result; 
    118             double* fResult = &result; 
    119  
    120             //Get the random-valued bytes to fill the int. 
    121             byte[] rand = new byte[sizeof(double)]; 
    122             NextBytes(rand); 
    123  
    124             //Copy the random buffer into the int. 
    125             fixed (byte* fRand = rand) 
    126             { 
    127                 byte* pResult = (byte*)fResult; 
    128                 byte* pRand = fRand; 
    129                 for (int i = 0; i != sizeof(double); ++i) 
    130                     *pResult++ = *pRand++; 
    131             } 
    132  
    133             return result; 
    134         } 
    135  
    136         public abstract override void NextBytes(byte[] buffer); 
     138        /// <summary> 
     139        /// Fills the elements of a specified array of bytes with random numbers. 
     140        /// </summary> 
     141        /// <param name="buffer">An array of bytes to contain random numbers.</param> 
     142        public abstract void NextBytes(byte[] buffer); 
    137143        #endregion 
    138144    } 
Note: See TracChangeset for help on using the changeset viewer.