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

  1. // CmStack.cpp
  2. // -----------------------------------------------------------------
  3. // Compendium - C++ Container Class Library
  4. // Copyright (C) 1992-1994, Glenn M. Poorman, All rights reserved
  5. // -----------------------------------------------------------------
  6. // Stack implementation.
  7. // -----------------------------------------------------------------
  8.  
  9. #include <cm/include/cmstack.h>
  10.  
  11.  
  12. // "CmStack" is the default stack constructor.
  13. //
  14. CmStack::CmStack() : CmLinkedList()
  15. {}
  16.  
  17.  
  18. // "CmStack" is the stack copy constructor.
  19. //
  20. CmStack::CmStack(const CmStack& St) : CmLinkedList(St)
  21. {}
  22.  
  23.  
  24. // "=" assignment operator copies the specified stack into this stack.
  25. //
  26. CmStack& CmStack::operator=(const CmStack& St)
  27. {
  28.   return (CmStack&) CmLinkedList::operator=(St);
  29. }
  30.  
  31.  
  32. // "push" places the specified object on top of the stack.
  33. //
  34. Bool CmStack::push(CmObject* pObj)
  35. {
  36.   return prepend(pObj);
  37. }
  38.  
  39.  
  40. // "pop" pops the top object off of the stack and returns it.
  41. //
  42. CmObject* CmStack::pop()
  43. {
  44.   return removeFirst();
  45. }
  46.  
  47.  
  48. // "peek" returns a pointer to the top object on the stack leaving the
  49. // object in place.
  50. // 
  51. CmObject* CmStack::peek() const
  52. {
  53.   return first();
  54. }
  55.