home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / gnu / g__lib / dldeque.hp < prev    next >
Text File  |  1993-07-23  |  3KB  |  134 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2. /* 
  3. Copyright (C) 1988 Free Software Foundation
  4.     written by Doug Lea (dl@rocky.oswego.edu)
  5.  
  6. This file is part of GNU CC.
  7.  
  8. GNU CC is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY.  No author or distributor
  10. accepts responsibility to anyone for the consequences of using it
  11. or for whether it serves any particular purpose or works at all,
  12. unless he says so in writing.  Refer to the GNU CC General Public
  13. License for full details.
  14.  
  15. Everyone is granted permission to copy, modify and redistribute
  16. GNU CC, but only under the conditions described in the
  17. GNU CC General Public License.   A copy of this license is
  18. supposed to have been given to you along with GNU CC so you
  19. can know your rights and responsibilities.  It should be in a
  20. file named COPYING.  Among other things, the copyright notice
  21. and this notice must be preserved on all copies.  
  22. */
  23.  
  24.  
  25. #ifndef _<T>DLDeque_h
  26. #pragma once
  27. #define _<T>DLDeque_h
  28.  
  29. #include "<T>.DLList.h"
  30. #include "<T>.Deque.h"
  31.  
  32. class <T>DLDeque : public <T>Deque
  33. {
  34.   <T>DLList    p;
  35.  
  36. public:
  37.                <T>DLDeque();
  38.                <T>DLDeque(const <T>DLDeque& d);
  39.                ~<T>DLDeque();
  40.  
  41.   void          operator = (const <T>DLDeque&);
  42.  
  43.   void          push(<T&> item); // insert at front
  44.   void          enq(<T&> item);  // insert at rear
  45.  
  46.   <T>&          front();
  47.   <T>&          rear();
  48.  
  49.   <T>           deq();
  50.   void          del_front();
  51.   void          del_rear();               
  52.  
  53.   void          clear();
  54.   int           empty();
  55.   int           full();
  56.   int           length();
  57.                
  58.   int           OK();
  59. };
  60.  
  61.  
  62. inline <T>DLDeque::<T>DLDeque() : p() {}
  63. inline <T>DLDeque::<T>DLDeque(const <T>DLDeque& d) : p(d.p) {}
  64.  
  65. inline <T>DLDeque::~<T>DLDeque() {}
  66.  
  67. inline void <T>DLDeque::push(<T&>item)
  68. {
  69.   p.prepend(item);
  70. }
  71.  
  72. inline void <T>DLDeque::enq(<T&>item)
  73. {
  74.   p.append(item);
  75. }
  76.  
  77. inline <T> <T>DLDeque::deq()
  78. {
  79.   return p.remove_front();
  80. }
  81.  
  82. inline <T>& <T>DLDeque::front()
  83. {
  84.   return p.front();
  85. }
  86.  
  87. inline <T>& <T>DLDeque::rear()
  88. {
  89.   return p.rear();
  90. }
  91.  
  92. inline void <T>DLDeque::del_front()
  93. {
  94.   p.del_front();
  95. }
  96.  
  97. inline void <T>DLDeque::del_rear()
  98. {
  99.   p.del_rear();
  100. }
  101.  
  102. inline void <T>DLDeque::operator =(const <T>DLDeque& s)
  103. {
  104.   p.operator = (s.p);
  105. }
  106.  
  107.  
  108. inline int <T>DLDeque::empty()
  109. {
  110.   return p.empty();
  111. }
  112.  
  113. inline int <T>DLDeque::full()
  114. {
  115.   return 0;
  116. }
  117.  
  118. inline int <T>DLDeque::length()
  119. {
  120.   return p.length();
  121. }
  122.  
  123. inline int <T>DLDeque::OK()
  124. {
  125.   return p.OK();
  126. }
  127.  
  128. inline void <T>DLDeque::clear()
  129. {
  130.   p.clear();
  131. }
  132.  
  133. #endif
  134.