home *** CD-ROM | disk | FTP | other *** search
/ Quake 'em / QUAKEEM.BIN / doom_i / program / reject10.exe / SOURCE.ZIP / LIST.HPP < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-25  |  2.1 KB  |  70 lines

  1. #ifndef __INC_LIST_HPP__
  2. #define __INC_LIST_HPP__
  3.  
  4. #include "base.hpp"
  5.  
  6.  
  7. /*********************************************************************************
  8. **
  9. **  CLASS: CLink : A link in a doubly linked list. Use this class as a 
  10. **                 base class to make linked lists of other classes.
  11. **
  12. **  PRIVATE MEMBERS:
  13. **        next = pointer to next CLink in the list or NULL if last in list
  14. **        prev = pointer to previous CLink in the list or NULL if first in list
  15. **
  16. **  PUBLIC MEMBERS:
  17. **        Next ()    = Returns a pointer to the next link in chain or NULL if 
  18. **                     last link in chain.
  19. **        Prev ()    = Returns a pointer to the previous link in chain or NULL if 
  20. **                     first link in chain.
  21. **
  22. *********************************************************************************/
  23.  
  24. class CLink : public CBase
  25. {
  26.      friend class CList; 
  27.      protected:
  28.           CLink *next;
  29.           CLink *prev;
  30.  
  31.      public:
  32.           CLink () : next(0), prev(0) {;}
  33.           CLink *Next () { return (next); }
  34.           CLink *Prev () { return (prev); }
  35.           virtual ~CLink () {;}
  36. };
  37.  
  38.  
  39.  
  40. /*********************************************************************************
  41. **
  42. **  CLASS: CList : A Doubly link list class
  43. **
  44. **  PRIVATE MEMBERS:
  45. **        _base = pointer to first CLink in the list or NULL if no items in list
  46. **
  47. **  PUBLIC MEMBERS:
  48. **        AddItem ()   = Adds a new CLink Object to the begining of the list.
  49. **        FirstItem () = Returns a pointer to the first CLink in the list.  
  50. **        DeleteItem ()= deletes an item and removes it from the list.  
  51. **        DeleteAll () = deletes all the items in the list.  
  52. **
  53. *********************************************************************************/
  54.  
  55. class CList : public CBase
  56. {
  57.      protected:
  58.           CLink *base;               
  59.  
  60.      public:
  61.           CList () { base = 0; }
  62.           void AddItem (CLink *link);
  63.           void DeleteItem (CLink *link);
  64.           void DeleteAll ();
  65.           CLink *FirstItem () { return (base); }
  66.           ~CList ();
  67. };
  68.  
  69. #endif
  70.