home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / pascal / rehack / contain / linklist.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-21  |  914 b   |  53 lines

  1. #include "linklist.h"
  2.  
  3. void link_index::operator -- ( int )
  4.  {
  5.   link_node *old_value = data;
  6.   link_node *last = NULL;
  7.  
  8.   old_value = data;
  9.   rewind();
  10.   while (data != old_value) {
  11.     last = data;
  12.     (*this)++;
  13.    }
  14.   data = last;
  15.  }
  16.  
  17. void link_index::put(containable *arg)
  18.  {
  19.   if (list == NULL) return;
  20.   put(new link_node(arg));
  21.  }
  22.  
  23. void link_index::destroy()
  24.  {
  25.   link_node   *old_node = data;
  26.  
  27.   if (data == NULL) return;
  28.   (*this)--;             // back up one.
  29.   if (data == NULL)
  30.     ((linked_list *)list)->head = old_node->next;
  31.    else
  32.     data->next = old_node->next;
  33.   delete old_node;
  34.   ((linked_list *)list)->object_count--;
  35.  }
  36.  
  37. void linked_list::put(containable *arg)
  38.  {
  39.   link_index i(*this);
  40.  
  41.   i.put(arg);
  42.  }
  43.  
  44. containable *linked_list::remove(containable *arg)
  45.  {
  46.   link_index i(*this);
  47.  
  48.   if (i.has(arg))
  49.     i.remove();
  50.   return arg;
  51.  }
  52.  
  53.