"Fossies" - the Fresh Open Source Software Archive

Member "bonnie++-2.00a/rand.h" (30 Jun 2016, 671 Bytes) of package /linux/privat/bonnie++-2.00a.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "rand.h" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 1.97_vs_1.97.3.

    1 #ifndef RAND_H
    2 #define RAND_H
    3 
    4 using namespace std;
    5 #include "port.h"
    6 #include <string>
    7 #include <stdio.h>
    8 #include <stdlib.h>
    9 
   10 class Rand
   11 {
   12 public:
   13   Rand() : m_arr(NULL) , m_size(0) , m_ind(0) { }
   14 
   15   bool seedFile(CPCCHAR name);
   16 
   17   void seedNum(UINT num);
   18 
   19   int getNum()
   20   {
   21     if(m_arr)
   22     {
   23       m_ind++;
   24       if(m_ind >= m_size)
   25         m_ind = 0;
   26       return m_arr[m_ind];
   27     }
   28     else
   29       return rand();
   30   }
   31 
   32   int getSize() { return m_size; }
   33 
   34   string getSeed() { return m_name; }
   35 
   36   void reset();
   37 
   38 private:
   39   int *m_arr;
   40   int m_size;
   41   int m_ind;
   42   string m_name;
   43   UINT m_init;
   44 
   45   Rand(const Rand &t);
   46   Rand & operator =(const Rand &t);
   47 };
   48 
   49 #endif