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

  1. #ifndef __INC_ILIST_HPP__
  2. #define __INC_ILIST_HPP__
  3.  
  4. #include "list.hpp"
  5. #include "xstring.hpp"
  6.  
  7.  
  8. /*********************************************************************************
  9. **
  10. **  CLASS: CIndexedLink : A link in a doubly linked list. Use this class as a 
  11. **                 base class to make linked lists of other classes.
  12. **
  13. **  PRIVATE MEMBERS:
  14. **        key = 
  15. **   
  16. **  PUBLIC MEMBERS:
  17. **
  18. **
  19. *********************************************************************************/
  20.  
  21. class CIndexedLink : public CLink
  22. {
  23.      friend class CIndexedList; 
  24.      private:
  25.           XString key;
  26.           
  27.      public:     
  28.           CIndexedLink (const XString s) : key(s) {;}
  29.  
  30.           CIndexedLink *Next () { return ((CIndexedLink *)next); }
  31.           CIndexedLink *Prev () { return ((CIndexedLink *)prev); }
  32.  
  33.           const XString GetKey () const { return key; }
  34.           int operator>  (const CIndexedLink& l) const { return (key > l.key); } 
  35.           int operator== (const CIndexedLink& l) const { return (key == l.key); } 
  36. };
  37.  
  38.  
  39. /*********************************************************************************
  40. **
  41. **  CLASS: CList : An Indexed Doubly link list class
  42. **
  43. **  PRIVATE MEMBERS:
  44. **        base = pointer to first CIndexedLink in the list or NULL if no items in list
  45. **
  46. **  PUBLIC MEMBERS:
  47. **        AddItem ()   = Adds a new CIndexedLink Item to the begining of the list.
  48. **        FirstItem () = Returns a pointer to the first CIndexedLink in the list.  
  49. **
  50. *********************************************************************************/
  51.  
  52. class CIndexedList : public CList
  53. {
  54.      public:
  55.           CIndexedList () { base = 0; }
  56.           void AddItem (CIndexedLink *link);
  57.           CIndexedLink *FirstItem () { return ((CIndexedLink *)base); }
  58.           CIndexedLink *operator[] (XString key);
  59. };
  60.  
  61. #endif
  62.