home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / bc45 / clobss.pak / STACK.CPO < prev    next >
Text File  |  1997-07-23  |  1KB  |  34 lines

  1. /*------------------------------------------------------------------------*/
  2. /*                                                                        */
  3. /*  STACK.CPP                                                             */
  4. /*                                                                        */
  5. /*  Copyright Borland International 1991, 1993                            */
  6. /*  All Rights Reserved                                                   */
  7. /*                                                                        */
  8. /*------------------------------------------------------------------------*/
  9.  
  10. #if !defined( __STACK_H )
  11. #include "classlib\obsolete\stack.h"
  12. #endif  // __STACK_H
  13.  
  14. void Stack::push( Object& toPush )
  15. {
  16.     list.add( toPush );
  17.     itemsInContainer++;
  18. }
  19.  
  20. Object& Stack::pop()
  21. {
  22.     Object& temp = list.peekHead();
  23.     list.detach( temp );
  24.     if( temp != NOOBJECT )
  25.         itemsInContainer--;
  26.     return temp;
  27. }
  28.  
  29. ContainerIterator& Stack::initIterator() const
  30. {
  31.     return *( (ContainerIterator *)new ListIterator( list ) );
  32. }
  33.  
  34.