home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_10_01 / 1001025a < prev    next >
Text File  |  1990-10-04  |  1KB  |  73 lines

  1. // Source Code for C++ D_List Class
  2. //
  3.  
  4. #include "listclas.h"
  5.  
  6.  
  7. void D_List::seek(long where, int start)
  8. {
  9.     long count;
  10.  
  11.     switch(start)
  12.     {
  13.         case SEEK_SET:
  14.             top();
  15.             for (count = 0; count < where; ++count)
  16.             {
  17.                 if ( at_end())
  18.                     break;
  19.                 next();
  20.             }
  21.         break;
  22.         case SEEK_CUR:
  23.             if (where > 0)
  24.             {
  25.                 for (count = 0; count < where; ++count)
  26.                 {
  27.                     if ( at_end())
  28.                         break;
  29.                     next();
  30.                 }
  31.             }
  32.             else
  33.             {
  34.                 for(count = 0; count > where; ++count)
  35.                 {
  36.                     if ( at_top())
  37.                        break;
  38.                     prev();
  39.                 }
  40.             }
  41.         break;
  42.     case SEEK_END:
  43.         end();
  44.         for(count = 0; count > where; ++count)
  45.         {
  46.             if ( at_top())
  47.                 break;
  48.             prev();
  49.         }
  50.         break;
  51.     }
  52.  
  53. }
  54.  
  55. long D_List::total()
  56. {
  57.     long thisone, count;
  58.  
  59.     thisone = tell();
  60.     top();
  61.     count = 0;
  62.     do
  63.     {
  64.         if ( ! at_end() )
  65.         {
  66.             ++count;
  67.             next();
  68.         }
  69.     } while( ! at_end() );
  70.     seek(thisone,SEEK_SET);
  71.     return(count);
  72. }
  73.