home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_09_05 / 9n05109a < prev    next >
Text File  |  1991-03-23  |  736b  |  44 lines

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