home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_09_03 / 9n03122b < prev    next >
Text File  |  1991-01-16  |  619b  |  39 lines

  1.  
  2. /*
  3.  * ln_seq.cpp - line number sequence implementation
  4.  */
  5. #include <stdio.h>
  6.  
  7. #include "ln_seq.h"
  8.  
  9. ln_seq::ln_seq()
  10.     {
  11.     first = last = 0;
  12.     }
  13.  
  14. void ln_seq::add(unsigned n)
  15.     {
  16.     listnode *p;
  17.     if (first == 0 || last->number != n)
  18.         {
  19.         p = new listnode;
  20.         p->number = n;
  21.         p->next = NULL;
  22.         if (first == 0)
  23.             first = p;
  24.         else
  25.             last->next = p;
  26.         last = p;
  27.         }
  28.     }
  29.  
  30. void ln_seq::print()
  31.     {
  32.     listnode *p;
  33.  
  34.     for (p = first; p != 0; p = p->next)
  35.         printf("%4d ", p->number);
  36.     }
  37.  
  38.  
  39.