proj home

Files   Classes   Functions   Hierarchy  

clockmisc.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int generateRandomSeed (double const waitms)
void generateRandomSeed ()
 Use time C library call srand( time(NULL).


Function Documentation

void generateRandomSeed (  ) 

Use time C library call srand( time(NULL).

int generateRandomSeed ( double const   waitms  ) 

Definition at line 21 of file clockmisc.cpp.

References aclock::diff_ms(), and aclock::measure().

Referenced by deckpontoon::shuffle().

00022 {
00023   double tm = 0.0;
00024 
00025   aclock clk;
00026 
00027   clk.measure();
00028 
00029   int sd=0;
00030 
00031   int kmax;
00032 
00033   int loops=0;
00034 
00035   for ( ;tm<waitms; )
00036   {
00037     kmax = rand() % 20;
00038     for (int k=1; k<kmax; ++k) 
00039       sd += rand();
00040 
00041     clk.measure();
00042     tm += clk.diff_ms();
00043 
00044     ++loops;
00045   }
00046 
00047   if (sd<0)
00048     sd *= -1;
00049 
00050 //  cout << "loops=" << loops << endl;
00051 //  cout << "sd=" << sd << endl;
00052 
00053   return sd;
00054 }


Generated on Fri Mar 4 00:49:42 2011 for Chelton Evans Source by  doxygen 1.5.8