home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 2.ddi / CLASSINC.ZIP / STACK.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  4.6 KB  |  182 lines

  1. /*------------------------------------------------------------------------*/
  2. /*                                                                        */
  3. /*  STACK.H                                                               */
  4. /*                                                                        */
  5. /*  Copyright Borland International 1991, 1992                            */
  6. /*  All Rights Reserved                                                   */
  7. /*                                                                        */
  8. /*------------------------------------------------------------------------*/
  9.  
  10. #if !defined( __STACK_H )
  11. #define __STACK_H
  12.  
  13. #if defined( TEMPLATES )
  14.  
  15.     #if !defined( __STACKS_H )
  16.     #include <Stacks.h>
  17.     #endif  // __STACKS_H
  18.  
  19.     #pragma option -Vo-
  20.     #if defined( __BCOPT__ ) && !defined( _ALLOW_po )
  21.     #pragma option -po-
  22.     #endif
  23.  
  24.     #define Stack   BI_TCStackAsList
  25.     #define PStack  PBI_TCStackAsList
  26.     #define RStack  RBI_TCStackAsList
  27.     #define RPStack RPBI_TCStackAsList
  28.     #define PCStack PCBI_TCStackAsList
  29.     #define RCStack RCBI_TCStackAsList
  30.  
  31.     _CLASSDEF( BI_TCStackAsList )
  32.  
  33.     #define StackIterator   BI_TCStackAsListIterator
  34.     #define PStackIterator  PBI_TCStackAsListIterator
  35.     #define RStackIterator  RBI_TCStackAsListIterator
  36.     #define RPStackIterator RPBI_TCStackAsListIterator
  37.     #define PCStackIterator PCBI_TCStackAsListIterator
  38.     #define RCStackIterator RCBI_TCStackAsListIterator
  39.  
  40.     _CLASSDEF( BI_TCStackAsListIterator )
  41.  
  42. #else   // TEMPLATES
  43.  
  44.     #if !defined( __CLSTYPES_H )
  45.     #include <ClsTypes.h>
  46.     #endif  // __CLSTYPES_H
  47.  
  48.     #if !defined( __CONTAIN_H )
  49.     #include <Contain.h>
  50.     #endif  // __CONTAIN_H
  51.  
  52.     #if !defined( __LIST_H )
  53.     #include <List.h>
  54.     #endif  // __LIST_H
  55.  
  56.     #pragma option -Vo-
  57.     #if defined( __BCOPT__ ) && !defined( _ALLOW_po )
  58.     #pragma option -po-
  59.     #endif
  60.  
  61.     _CLASSDEF(Stack)
  62.  
  63.     class _CLASSTYPE Stack : public Container
  64.     {
  65.  
  66.     public:
  67.  
  68.         void push( Object _FAR & );
  69.         Object _FAR & pop();
  70.         Object _FAR & top() const
  71.             {
  72.             return list.peekHead();
  73.             }
  74.  
  75.         virtual void flush( DeleteType dt = DefDelete )
  76.             {
  77.             list.flush( dt );
  78.             }
  79.  
  80.         virtual int isEmpty() const
  81.             {
  82.             return list.isEmpty();
  83.             }
  84.  
  85.         virtual countType getItemsInContainer() const
  86.             {
  87.             return list.getItemsInContainer();
  88.             }
  89.  
  90.         virtual void forEach( iterFuncType f, void _FAR *arg )
  91.             {
  92.             list.forEach( f, arg );
  93.             }
  94.  
  95.         virtual Object _FAR & firstThat( condFuncType f, void _FAR *arg ) const
  96.             {
  97.             return list.firstThat( f, arg );
  98.             }
  99.  
  100.         virtual Object _FAR & lastThat( condFuncType f, void _FAR *arg ) const
  101.             {
  102.             return list.lastThat( f, arg );
  103.             }
  104.  
  105.         virtual classType isA() const
  106.             {
  107.             return stackClass;
  108.             }
  109.  
  110.         virtual char _FAR *nameOf() const
  111.             {
  112.             return "Stack";
  113.             }
  114.  
  115.         virtual hashValueType hashValue() const
  116.             {
  117.             return list.hashValue();
  118.             }
  119.  
  120.         virtual int isEqual( const Object& obj ) const
  121.             {
  122.             return list.isEqual( obj );
  123.             }
  124.  
  125.         virtual int isSortable() const
  126.             {
  127.             return list.isSortable();
  128.             }
  129.  
  130.         virtual int isAssociation() const
  131.             {
  132.             return list.isAssociation();
  133.             }
  134.  
  135.         virtual void printOn( ostream& os ) const
  136.             {
  137.             list.printOn( os );
  138.             }
  139.  
  140.         virtual void printHeader( ostream& os ) const
  141.             {
  142.             list.printHeader( os );
  143.             }
  144.  
  145.         virtual void printSeparator( ostream& os ) const
  146.             {
  147.             list.printSeparator( os );
  148.             }
  149.  
  150.         virtual void printTrailer( ostream& os ) const
  151.             {
  152.             list.printTrailer( os );
  153.             }
  154.  
  155.         virtual ContainerIterator _FAR & initIterator() const;
  156.  
  157.         int ownsElements()
  158.             {
  159.             return list.ownsElements();
  160.             }
  161.  
  162.         void ownsElements( int del )
  163.             { 
  164.             list.ownsElements( del );
  165.             }
  166.  
  167.     private:
  168.  
  169.         List list;
  170.  
  171.     };
  172.  
  173. #endif  // TEMPLATES
  174.  
  175. #if defined( __BCOPT__ ) && !defined( _ALLOW_po )
  176. #pragma option -po.
  177. #endif
  178. #pragma option -Vo.
  179.  
  180. #endif  // __STACK_H
  181.  
  182.