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

  1. #include "double.h"
  2.  
  3. double_node::double_node(containable *arg) : link_node(arg)
  4.  {
  5.   last = NULL;
  6.  }
  7.  
  8. void double_index::put(containable *arg)
  9.  {
  10.   double_node *last;
  11.  
  12.   if (list == NULL) return;
  13.   last = node()->last;
  14.   abstract_index::put(new double_node(arg));
  15.   node()->last = last;
  16.   if (node()->next == NULL)
  17.     d_list()->tail = node();
  18.    else
  19.     next_node()->last = node();
  20.  }
  21.  
  22. void double_index::operator -- ( int )
  23.  {
  24.   data = node()->last;
  25.  }
  26.  
  27. void double_index::destroy()
  28.  {
  29.   if (data == NULL) return;
  30.   if (node()->next == NULL)
  31.     d_list()->tail = node()->last;
  32.    else
  33.     next_node()->last = node()->last;
  34.   abstract_index::destroy();
  35.  }
  36.  
  37. void double_index::to_end()
  38.  {
  39.   if (list == NULL)
  40.     return;
  41.   data = d_list()->tail;
  42.  }
  43.  
  44. double_list::double_list()
  45.  {
  46.   tail = NULL;
  47.  }
  48.  
  49. void double_list::put(containable *arg)
  50.  {
  51.   double_index i(*this);
  52.  
  53.   i.put(arg);
  54.  }
  55.  
  56. void double_list::destroy()
  57.  {
  58.   if (head != NULL && head->next != NULL)
  59.     ((double_node *) head->next)->last = NULL;
  60.   abstract_list::destroy();
  61.  }
  62.  
  63. containable *double_list::remove(containable *arg)
  64.  {
  65.   double_index i(*this);
  66.  
  67.   if (i.has(arg))
  68.     i.remove();
  69.   return arg;
  70.  }
  71.  
  72.