home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / CTECHAPP.ZIP / CONTAINR.ZIP / SINGLIST.HPP < prev    next >
C/C++ Source or Header  |  1990-01-27  |  1KB  |  59 lines

  1. //  Header:     SingList (Singly-Linked Lists)
  2. //  Version:    3.20
  3. //
  4. //  Language:   C++ 2.0
  5. //  Environ:    Any
  6. //
  7. //  Purpose:    Provides a general set of singly-linked list classes
  8. //
  9. //  Written by: Scott Robert Ladd
  10.  
  11. #if !defined(__SINGLIST_HPP)
  12. #define __SINGLIST_HPP 1
  13.  
  14. #include "Containr.hpp"
  15.  
  16. class SinglyLinkedList : public Container
  17.     {
  18.     protected:
  19.         // structure of a node in a list
  20.         struct ListNode
  21.             {
  22.             ListNode  *  Next;
  23.             void      *  DataPtr;
  24.             };
  25.  
  26.         ListNode * Head;  // pointer to first node
  27.         ListNode * Tail;  // pointer to the last node
  28.  
  29.         // duplication method
  30.         void Copy(const SinglyLinkedList & sl);
  31.  
  32.     public:
  33.         // constructor
  34.         SinglyLinkedList();
  35.  
  36.         // copy contructor
  37.         SinglyLinkedList(const SinglyLinkedList & sl);
  38.  
  39.         // assignment operator
  40.         void operator = (const SinglyLinkedList & sl);
  41.  
  42.         // destructor
  43.         ~SinglyLinkedList();
  44.  
  45.         // store an item
  46.         virtual int Store(void * item) = 0;
  47.  
  48.         // examine an item
  49.         virtual void * Examine() = 0;
  50.  
  51.         // retrieve an item
  52.         virtual void * Retrieve() = 0;
  53.  
  54.         // remove all items from a list
  55.         virtual void Empty();
  56.     };
  57.  
  58. #endif
  59.