home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c221 / 6.ddi / MWHC.006 / 21 < prev    next >
Encoding:
Text File  |  1992-06-07  |  2.9 KB  |  96 lines

  1. #ifndef  __RWDLIST_H__
  2. #define  __RWDLIST_H__
  3. pragma push_align_members(64);
  4.  
  5. /*
  6.  * Declarations for Doubly-linked lists.
  7.  *
  8.  * $Header:   E:/vcs/rw/dlist.h_v   1.2   18 Feb 1992 09:54:18   KEFFER  $
  9.  *
  10.  ****************************************************************************
  11.  *
  12.  * Rogue Wave 
  13.  * P.O. Box 2328
  14.  * Corvallis, OR 97339
  15.  * Voice: (503) 754-3010    FAX: (503) 757-6650
  16.  *
  17.  * Copyright (C) 1989, 1990, 1991. This software is subject to copyright 
  18.  * protection under the laws of the United States and other countries.
  19.  *
  20.  ***************************************************************************
  21.  *
  22.  * $Log:   E:/vcs/rw/dlist.h_v  $
  23.  * 
  24.  *    Rev 1.2   18 Feb 1992 09:54:18   KEFFER
  25.  * 
  26.  *    Rev 1.1   28 Oct 1991 09:08:12   keffer
  27.  * Changed inclusions to <rw/xxx.h>
  28.  * 
  29.  *    Rev 1.0   28 Jul 1991 08:14:22   keffer
  30.  * Tools.h++ V4.0.5 PVCS baseline version
  31.  *
  32.  */
  33.  
  34. #include "rw/slist.h"
  35.  
  36. // Link in Doubly linked list:
  37. class RWExport RWDlink : public RWSlink {
  38. friend class RWExport RWDlist;
  39. friend class RWExport RWDlistIterator;
  40. protected:
  41.   RWDlink*        prevDlink;      // Pointer to previous link.
  42.   RWDlink(void* a, RWDlink* p = 0, RWDlink* n = 0) : RWSlink(a,n)
  43.     { prevDlink = p; }
  44. };
  45.  
  46. // Doubly linked list:
  47.  
  48. class RWExport RWDlist : public RWSlist {
  49. friend class RWExport RWDlistIterator;
  50. private:
  51.   void            deleteLink(RWDlink*);
  52.   RWDlink*        findLink(int) const;
  53.   void            insertAfterLink(RWDlink*, void*);
  54. public:
  55.   RWDlist()        { }
  56.   RWDlist(void* a);
  57.   RWDlist(const RWDlist&);
  58.   ~RWDlist()        {clear();} 
  59.   void            operator=(const RWDlist&);
  60.  
  61.   /********************* Member functions **************************/
  62.   void*            append(void*);        // Add at tail of list.
  63.   void            clear();
  64.   void*             get();            // Return and delete value at head of list
  65.   void*            insert(void* a) { return RWDlist::append(a); }
  66.   void*            insertAfter(int, void*);
  67.   void*            prepend(void*);
  68.   void*            remove(RWtestGeneric, const void*);
  69.   void*         removeReference(const void*);
  70. };
  71.  
  72. // Iterator for doubly linked list (moves iterator through the list):
  73. class RWExport RWDlistIterator : public RWSlistIterator {
  74. public:
  75.   // constructor: start with iterator positioned at last link
  76.   RWDlistIterator(RWDlist& s); 
  77.   
  78.   /****************** Special RWDlistIterator functions ************************/
  79.   void*            insertAfterPoint(void*);    // Insert item behind iterator.
  80.   void            operator--();            // Move iterator back one link.
  81.   void            operator-=(int n);        // Move iterator back n links.
  82.   void*            remove();            // Remove current item
  83.   void*            removeNext(RWtestGeneric, const void*);
  84.   void*            removeNextReference(const void*);
  85. };
  86.  
  87.  
  88. /****************** RWDlistIterator inlines **************************/
  89.  
  90. // constructor: start with iterator positioned at last link
  91. Inline
  92. RWDlistIterator::RWDlistIterator(RWDlist& s) : RWSlistIterator(s) { }
  93.  
  94. pragma pop_align_members();
  95. #endif  /* __RWDLIST_H__ */
  96.