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

  1. #ifndef __ABSLIST_H
  2. #define __ABSLIST_H
  3.  
  4. // ╔════════════════════════════════════════════════╗
  5. // ║ Linklist.h, linklist.cpp                       ║
  6. // ╟────────────────────────────────────────────────╢
  7. // ║ Linked list                                    ║
  8. // ╟────────────────────────────────────────────────╢
  9. // ║ Written by Gus Smedstad                        ║
  10. // ╟────────────────────────────────────────────────╢
  11. // ║ Copyright 1990-91 NoGate Consulting            ║
  12. // ╚════════════════════════════════════════════════╝
  13.  
  14. #ifndef __CONTAIN_H
  15. #include "contain.h"
  16. #endif
  17.  
  18. class link_node {
  19. public:
  20.   containable *data;
  21.   link_node *next;
  22.   link_node(containable *arg = NULL);
  23.   ~link_node();
  24.  
  25.   containable *item() { return data; };
  26.   void         replace(containable *arg) { data = arg; };
  27.   void         empty() { data = NULL; };
  28.  };
  29.  
  30. class abstract_list : public container {
  31.   friend abstract_index;
  32. protected:
  33.   link_node *head;
  34. public:
  35.   abstract_list();
  36.   virtual ~abstract_list();
  37.   virtual void           put(containable *arg) = 0;
  38.   virtual void           destroy();
  39.           void           empty(char kill = 0);
  40.           containable   *remove();
  41.           int            has(containable *arg, int exact = 1);
  42.           abstract_list& operator << (containable *arg)
  43.               { put(arg); return *this; };
  44.  };
  45.  
  46. class abstract_index {
  47. protected:
  48.   link_node     *data;
  49.   abstract_list *list;
  50.   void         put(link_node *);
  51. public:
  52.   abstract_index(abstract_list & base);
  53.   void         attach(abstract_list &base);
  54.   void         rewind();
  55.   int          has(containable *arg, int exact = 1);
  56.   virtual void destroy();
  57.   containable *remove();
  58.   containable *item() const { return data->item(); };
  59.   void         replace(containable *arg) { data->replace(arg); };
  60.   void         operator ++ ( int ) { data = data->next; };
  61.   virtual void operator -- ( int );
  62.                operator int() const { return data != NULL; };
  63.  };
  64.  
  65. #endif