home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / OTHERUTI / TCPP10-8.ZIP / CLASSEXM.ZIP / QUEUETST.CPP < prev    next >
Text File  |  1990-09-26  |  3KB  |  108 lines

  1. //
  2. // This file contains proprietary information of Borland International.
  3. // Copying or reproduction without prior written approval is prohibited.
  4. //
  5. // Copyright (c) 1990
  6. // Borland International
  7. // 1800 Scotts Valley Dr.
  8. // Scotts Valley, CA 95066
  9. // (408) 438-8400
  10. //
  11.  
  12. // Contents -----------------------------------------------------------------
  13. //
  14. //      main
  15. //
  16. // Description
  17. //
  18. //      Contains a simple example program for class Queue.
  19. //
  20. // End ---------------------------------------------------------------------
  21.  
  22. // Interface Dependencies ---------------------------------------------------
  23.  
  24. // None
  25.  
  26. // End Interface Dependencies ------------------------------------------------
  27.  
  28. // Implementation Dependencies ----------------------------------------------
  29.  
  30. #ifndef __IOSTREAM_H
  31. #include <iostream.h>
  32. #define __IOSTREAM_H
  33. #endif
  34.  
  35. #ifndef __DOS_H
  36. #include <dos.h>
  37. #define __DOS_H
  38. #endif
  39.  
  40. #ifndef __STDLIB_H
  41. #include <stdlib.h>
  42. #define __STDLIB_H
  43. #endif
  44.  
  45. #ifndef __LTIME_H
  46. #include <ltime.h>
  47. #endif
  48.  
  49. #ifndef __QUEUE_H
  50. #include <queue.h>
  51. #endif
  52.  
  53. // End Implementation Dependencies -------------------------------------------
  54.  
  55.  
  56. // Function //
  57.  
  58. int main()
  59.  
  60. // Summary -----------------------------------------------------------------
  61. //
  62. //      Illustrates a use of the Queue class.  Saves
  63. //      the current time in a queue, then waits for a random length of
  64. //      time before saving the current time in a queue.  After 7 samplings
  65. //      have been entered in the queue, the queue is printed.
  66. //
  67. //      Usage:  queuetst
  68. //
  69. // Return Value
  70. //
  71. //      noError
  72. //
  73. //      Returns a 0 if no error occurs during execution, a 1 otherwise.
  74. //
  75. // End ---------------------------------------------------------------------
  76. {
  77.     Queue timeLine;
  78.  
  79.     cout << "\nSampling";
  80.     for ( int i = 0; i < 7; i++ )
  81.     {
  82.         struct time snapShot;
  83.         gettime( &snapShot );
  84.         Time sample( snapShot.ti_hour,
  85.                      snapShot.ti_min,
  86.                      snapShot.ti_sec,
  87.                      snapShot.ti_hund );
  88.  
  89.         timeLine.put ( *(new Time( sample )) );
  90.         cout << ".";
  91.         delay( rand() % 5000 );
  92.     }
  93.  
  94.     cout << "\nThe timing samples are:\n\n";
  95.  
  96.     while( !timeLine.isEmpty() )
  97.         {
  98.         Time& sampleTime = (Time&)timeLine.get();
  99.         cout << sampleTime << "\n";
  100.         delete &sampleTime;
  101.         } // end for all element in the queue.
  102.  
  103.     return 0;
  104. }
  105. // End Function main //
  106.  
  107.  
  108.