home *** CD-ROM | disk | FTP | other *** search
/ PC Media 7 / PC MEDIA CD07.iso / share / prog / cm / cmdeque.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-06  |  1.6 KB  |  80 lines

  1. // CmDeque.cpp
  2. // -----------------------------------------------------------------
  3. // Compendium - C++ Container Class Library
  4. // Copyright (C) 1992-1994, Glenn M. Poorman, All rights reserved
  5. // -----------------------------------------------------------------
  6. // Deque (double ended queue) implementation.
  7. // -----------------------------------------------------------------
  8.  
  9. #include <cm/include/cmdeque.h>
  10.  
  11.  
  12. // "CmDeque" is the default deque constructor.
  13. //
  14. CmDeque::CmDeque() : CmLinkedList()
  15. {}
  16.  
  17.  
  18. // "CmDeque" is the deque copy constructor.
  19. //
  20. CmDeque::CmDeque(const CmDeque& Dq) : CmLinkedList(Dq)
  21. {}
  22.  
  23.  
  24. // "=" assignment operator copies the specified deque into this deque.
  25. //
  26. CmDeque& CmDeque::operator=(const CmDeque& Dq)
  27. {
  28.   return (CmDeque&) CmLinkedList::operator=(Dq);
  29. }
  30.  
  31.  
  32. // "pushLeft" places the specified object into the queue left.
  33. //
  34. Bool CmDeque::pushLeft(CmObject* pObj)
  35. {
  36.   return prepend(pObj);
  37. }
  38.  
  39.  
  40. // "pushRight" places the specified object into the queue right.
  41. //
  42. Bool CmDeque::pushRight(CmObject* pObj)
  43. {
  44.   return append(pObj);
  45. }
  46.  
  47.  
  48. // "popLeft" pops the left object from the deque.
  49. //
  50. CmObject* CmDeque::popLeft()
  51. {
  52.   return removeFirst();
  53. }
  54.  
  55.  
  56. // "popRight" pops the right object from the deque.
  57. //
  58. CmObject* CmDeque::popRight()
  59. {
  60.   return removeLast();
  61. }
  62.  
  63.  
  64. // "peekLeft" returns a pointer to the left object in the deque leaving the
  65. // object in place.
  66. // 
  67. CmObject* CmDeque::peekLeft() const
  68. {
  69.   return first();
  70. }
  71.  
  72.  
  73. // "peekRight" returns a pointer to the right object in the deque leaving the
  74. // object in place.
  75. // 
  76. CmObject* CmDeque::peekRight() const
  77. {
  78.   return last();
  79. }
  80.