home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / bc45 / classinc.pak / STACKS.H < prev    next >
C/C++ Source or Header  |  1997-07-23  |  24KB  |  777 lines

  1. /*------------------------------------------------------------------------*/
  2. /*                                                                        */
  3. /*  STACKS.H                                                              */
  4. /*                                                                        */
  5. /*  Copyright (c) 1991, 1994 Borland International                        */
  6. /*  All Rights Reserved                                                   */
  7. /*                                                                        */
  8. /*------------------------------------------------------------------------*/
  9.  
  10. #if !defined( CLASSLIB_STACKS_H )
  11. #define CLASSLIB_STACKS_H
  12.  
  13. #if !defined( __CHECKS_H )
  14. #include <checks.h>
  15. #endif
  16.  
  17. #if !defined( CLASSLIB_DEFS_H )
  18. #include <classlib/defs.h>
  19. #endif
  20.  
  21. #if !defined( CLASSLIB_SHDDEL_H )
  22. #include <classlib/shddel.h>
  23. #endif
  24.  
  25. #if !defined( CLASSLIB_VECTIMP_H )
  26. #include <classlib/vectimp.h>
  27. #endif
  28.  
  29. #if !defined( CLASSLIB_LISTIMP_H )
  30. #include <classlib/listimp.h>
  31. #endif
  32.  
  33. #pragma option -Vo-
  34. #if defined( BI_CLASSLIB_NO_po )
  35. #pragma option -po-
  36. #endif
  37.  
  38. /*------------------------------------------------------------------------*/
  39. /*                                                                        */
  40. /*  template <class Vect, class T> class TStackAsVectorImp                */
  41. /*                                                                        */
  42. /*  Implements the fundamental stack operations, using a vector           */
  43. /*  as the underlying implementation.  The type Vect specifies the        */
  44. /*  form of the vector, either a TVectorImp<T0> or a                      */
  45. /*  TIVectorImp<T0>.  The type T specifies the type of the                */
  46. /*  objects to be put on the stack.  When using TVectorImp<T0>,           */
  47. /*  T should be the same as T0. When using TIVectorImp<T0>, T             */
  48. /*  should be of type pointer to T0.  See TStackAsVector and              */
  49. /*  TIStackAsVector for examples.                                         */
  50. /*                                                                        */
  51. /*------------------------------------------------------------------------*/
  52.  
  53. template <class Vect, class T> class TStackAsVectorImp
  54. {
  55.  
  56. public:
  57.  
  58.     TStackAsVectorImp( unsigned max = DEFAULT_STACK_SIZE ) :
  59.         Data(max),
  60.         Current(0)
  61.         {
  62.         }
  63.  
  64.     int IsEmpty() const
  65.         {
  66.         return Current == 0;
  67.         }
  68.  
  69.     int IsFull() const
  70.         {
  71.         return Current == Data.Limit();
  72.         }
  73.  
  74.     int GetItemsInContainer() const
  75.         {
  76.         return Current;
  77.         }
  78.  
  79. #if defined( BI_OLDNAMES )
  80.     int isEmpty() const { return IsEmpty(); }
  81.     int isFull() const { return IsFull(); }
  82.     int getItemsInContainer() const { return GetItemsInContainer(); }
  83. #endif  // BI_OLDNAMES
  84.  
  85. protected:
  86.  
  87.     Vect Data;
  88.     unsigned Current;
  89.  
  90. };
  91.  
  92. #if defined( BI_OLDNAMES )
  93. #define BI_StackAsVectorImp TStackAsVectorImp
  94. #endif
  95.  
  96. /*------------------------------------------------------------------------*/
  97. /*                                                                        */
  98. /*  template <class T,class Alloc> class TMStackAsVector                  */
  99. /*  template <class T,class Alloc> class TMStackAsVectorIterator          */
  100. /*                                                                        */
  101. /*  Implements a managed stack of objects of type T, using a vector as    */
  102. /*  the underlying implementation.                                        */
  103. /*                                                                        */
  104. /*------------------------------------------------------------------------*/
  105.  
  106. template <class T, class Alloc> class TMStackAsVectorIterator;
  107.  
  108. template <class T,class Alloc> class TMStackAsVector :
  109.     public TStackAsVectorImp<TMVectorImp<T,Alloc>,T>
  110. {
  111.  
  112.     typedef TStackAsVectorImp<TMVectorImp<T,Alloc>,T> Parent;
  113.  
  114. public:
  115.  
  116.     friend class TMStackAsVectorIterator<T,Alloc>;
  117.  
  118.     typedef void (*IterFunc)(T&, void *);
  119.     typedef int  (*CondFunc)(const T&, void *);
  120.  
  121.     TMStackAsVector( unsigned max = DEFAULT_STACK_SIZE ) :
  122.         TStackAsVectorImp<TMVectorImp<T,Alloc>,T>( max )
  123.         {
  124.         }
  125.  
  126.     void Push( const T& t )
  127.         {
  128.         PRECONDITION( Current < Data.Limit() );
  129.         Data[Current++] = t;
  130.         }
  131.  
  132.     T Pop()
  133.         {
  134.         PRECONDITION( Current > 0 );
  135.         return Data[--Current];
  136.         }
  137.  
  138.     const T& Top() const
  139.         {
  140.         PRECONDITION( Current > 0 );
  141.         return Data[Current-1];
  142.         }
  143.  
  144.     void ForEach( IterFunc iter, void *args )
  145.         {
  146.         if( !IsEmpty() )
  147.             Data.ForEach( iter, args, 0, Current );
  148.         }
  149.  
  150.     T *FirstThat( CondFunc cond, void *args ) const
  151.         {
  152.         if( IsEmpty() )
  153.             return 0;
  154.         return Data.FirstThat( cond, args, 0, Current );
  155.         }
  156.  
  157.     T *LastThat( CondFunc cond, void *args ) const
  158.         {
  159.         if( IsEmpty() )
  160.             return 0;
  161.         return Data.LastThat( cond, args, 0, Current );
  162.         }
  163.  
  164.     void Flush()
  165.         {
  166.         Current = 0;
  167.         }
  168.  
  169. #if defined( BI_OLDNAMES )
  170.     void push( const T& t ) { Push(t); }
  171.     T pop() { return Pop(); }
  172.     const T& top() const { return Top(); }
  173.     void forEach( IterFunc iter, void *args )
  174.         { ForEach( iter, args ); }
  175.     T *firstThat( CondFunc cond, void *args ) const
  176.         { return FirstThat( cond, args ); }
  177.     T *lastThat( CondFunc cond, void *args ) const
  178.         { return LastThat( cond, args ); }
  179.     void flush( TShouldDelete::DeleteType = TShouldDelete::DefDelete )
  180.         {
  181.         Flush();
  182.         }
  183.  
  184. #endif  // BI_OLDNAMES
  185.  
  186. };
  187.  
  188. template <class T,class Alloc> class TMStackAsVectorIterator :
  189.     public TMVectorIteratorImp<T,Alloc>
  190. {
  191.  
  192. public:
  193.  
  194.     TMStackAsVectorIterator( const TMStackAsVector<T,Alloc>& s ) :
  195.         TMVectorIteratorImp<T,Alloc>(s.Data,0,s.Current)
  196.         {
  197.         }
  198.  
  199. };
  200.  
  201. #if defined( BI_OLDNAMES )
  202. #define BI_MStackAsVector TMStackAsVector
  203. #define BI_MStackAsVectorIterator TMStackAsVectorIterator
  204. #endif
  205.  
  206. /*------------------------------------------------------------------------*/
  207. /*                                                                        */
  208. /*  template <class T> class TStackAsVector                               */
  209. /*  template <class T> class TStackAsVectorIterator                       */
  210. /*                                                                        */
  211. /*  Implements a stack of objects of type T, using a vector as            */
  212. /*  the underlying implementation and TStandardAllocator as its memory    */
  213. /*  manager.                                                              */
  214. /*                                                                        */
  215. /*------------------------------------------------------------------------*/
  216.  
  217. template <class T> class TStackAsVector :
  218.     public TMStackAsVector<T,TStandardAllocator>
  219. {
  220.  
  221. public:
  222.  
  223.     TStackAsVector( unsigned max = DEFAULT_STACK_SIZE ) :
  224.         TMStackAsVector<T,TStandardAllocator>( max )
  225.         {
  226.         }
  227.  
  228. };
  229.  
  230. template <class T> class TStackAsVectorIterator :
  231.     public TMStackAsVectorIterator<T,TStandardAllocator>
  232. {
  233.  
  234. public:
  235.  
  236.     TStackAsVectorIterator( const TStackAsVector<T>& s ) :
  237.         TMStackAsVectorIterator<T,TStandardAllocator>(s)
  238.         {
  239.         }
  240.  
  241. };
  242.  
  243. #if defined( BI_OLDNAMES )
  244. #define BI_StackAsVector TStackAsVector
  245. #define BI_StackAsVectorIterator TStackAsVectorIterator
  246. #endif
  247.  
  248. /*------------------------------------------------------------------------*/
  249. /*                                                                        */
  250. /*  template <class T,class Alloc> class TMIStackAsVector                 */
  251. /*  template <class T,class Alloc> class TMIStackAsVectorIterator         */
  252. /*                                                                        */
  253. /*  Implements a managed stack of pointers to objects of type T,          */
  254. /*  using a vector as the underlying implementation.                      */
  255. /*                                                                        */
  256. /*------------------------------------------------------------------------*/
  257.  
  258. template <class T,class Alloc> class TMIStackAsVectorIterator;
  259.  
  260. template <class T,class Alloc> class TMIStackAsVector :
  261.     public TStackAsVectorImp<TMIVectorImp<T,Alloc>, T * >,
  262.     public TShouldDelete
  263. {
  264.  
  265.     typedef TStackAsVectorImp<TMIVectorImp<T,Alloc>, T * > Parent;
  266.  
  267. public:
  268.  
  269.     friend class TMIStackAsVectorIterator<T,Alloc>;
  270.  
  271.     typedef void (*IterFunc)(T&, void *);
  272.     typedef int  (*CondFunc)(const T&, void *);
  273.  
  274.     TMIStackAsVector( unsigned max = DEFAULT_STACK_SIZE ) :
  275.         TStackAsVectorImp<TMIVectorImp<T,Alloc>,T *>( max )
  276.         {
  277.         }
  278.  
  279.     ~TMIStackAsVector()
  280.         {
  281.         Flush();
  282.         }
  283.  
  284.     void Push( T *t )
  285.         {
  286.         PRECONDITION( Current < Data.Limit() );
  287.         Data[Current++] = t;
  288.         }
  289.  
  290.     T *Pop()
  291.         {
  292.         PRECONDITION( Current > 0 );
  293.         return Data[--Current];
  294.         }
  295.  
  296.     T *const& Top() const
  297.         {
  298.         PRECONDITION( Current > 0 );
  299.         return Data[Current-1];
  300.         }
  301.  
  302.     void Flush( DeleteType dt = DefDelete )
  303.         {
  304.         Data.Flush( DelObj(dt), Current );
  305.         Current = 0;
  306.         }
  307.  
  308.     void ForEach( IterFunc iter, void *args )
  309.         {
  310.         if( !IsEmpty() )
  311.             Data.ForEach( iter, args, 0, Current );
  312.         }
  313.  
  314.     T *FirstThat( CondFunc cond, void *args ) const
  315.         {
  316.         if( IsEmpty() )
  317.             return 0;
  318.         return Data.FirstThat( cond, args, 0, Current );
  319.         }
  320.  
  321.     T *LastThat( CondFunc cond, void *args ) const
  322.         {
  323.         if( IsEmpty() )
  324.             return 0;
  325.         return Data.LastThat( cond, args, 0, Current );
  326.         }
  327.  
  328. #if defined( BI_OLDNAMES )
  329.     void push( T *t ) { Push(t); }
  330.     T *pop() { return Pop(); }
  331.     T *top() const { return Top(); }
  332.     void flush( DeleteType dt = DefDelete ) { Flush(dt); }
  333.     void forEach( IterFunc iter, void *args )
  334.         { ForEach( iter, args ); }
  335.     T *firstThat( CondFunc cond, void *args ) const
  336.         { return FirstThat( cond, args ); }
  337.     T *lastThat( CondFunc cond, void *args ) const
  338.         { return LastThat( cond, args ); }
  339. #endif  // BI_OLDNAMES
  340.  
  341. };
  342.  
  343. template <class T,class Alloc> class TMIStackAsVectorIterator :
  344.     public TMIVectorIteratorImp<T,Alloc>
  345. {
  346.  
  347. public:
  348.  
  349.     TMIStackAsVectorIterator( const TMIStackAsVector<T,Alloc>& s ) :
  350.         TMIVectorIteratorImp<T,Alloc>(s.Data,0,s.Current)
  351.         {
  352.         }
  353.  
  354. };
  355.  
  356. #if defined( BI_OLDNAMES )
  357. #define BI_MIStackAsVector TMIStackAsVector
  358. #define BI_MIStackAsVectorIterator TMIStackAsVectorIterator
  359. #endif
  360.  
  361. /*------------------------------------------------------------------------*/
  362. /*                                                                        */
  363. /*  template <class T> class TIStackAsVector                              */
  364. /*  template <class T> class TIStackAsVectorIterator                      */
  365. /*                                                                        */
  366. /*  Implements a stack of pointers to objects of type T,                  */
  367. /*  using a vector as the underlying implementation and                   */
  368. /*  TStandardAllocator as its memory manager.                             */
  369. /*                                                                        */
  370. /*------------------------------------------------------------------------*/
  371.  
  372. template <class T> class TIStackAsVector :
  373.     public TMIStackAsVector<T,TStandardAllocator>
  374. {
  375.  
  376. public:
  377.  
  378.     TIStackAsVector( unsigned max = DEFAULT_STACK_SIZE ) :
  379.         TMIStackAsVector<T,TStandardAllocator>( max )
  380.         {
  381.         }
  382.  
  383. };
  384.  
  385. template <class T> class TIStackAsVectorIterator :
  386.     public TMIStackAsVectorIterator<T,TStandardAllocator>
  387. {
  388.  
  389. public:
  390.  
  391.     TIStackAsVectorIterator( const TIStackAsVector<T>& s ) :
  392.         TMIStackAsVectorIterator<T,TStandardAllocator>(s)
  393.         {
  394.         }
  395.  
  396. };
  397.  
  398. #if defined( BI_OLDNAMES )
  399. #define BI_IStackAsVector TIStackAsVector
  400. #define BI_IStackAsVectorIterator TIStackAsVectorIterator
  401. #endif
  402.  
  403. /*------------------------------------------------------------------------*/
  404. /*                                                                        */
  405. /*  template <class Stk, class T> class TStackAsListImp                   */
  406. /*                                                                        */
  407. /*  Implements the fundamental stack operations, using a stack            */
  408. /*  as the underlying implementation.  The type Stk specifies the         */
  409. /*  form of the stack, either a TStackImp<T0> or a                        */
  410. /*  TIStackImp<T0>.  The type T specifies the type of the                 */
  411. /*  objects to be put on the stack.  When using TStackImp<T0>,            */
  412. /*  T should be the same as T0. When using TIStackImp<T0>, T              */
  413. /*  should be of type pointer to T0.  See TStackAsList and                */
  414. /*  TIStackAsList for examples.                                           */
  415. /*                                                                        */
  416. /*------------------------------------------------------------------------*/
  417.  
  418. template <class Stk, class T> class TStackAsListImp
  419. {
  420.  
  421. public:
  422.  
  423.     TStackAsListImp()
  424.         {
  425.         }
  426.  
  427.     int IsEmpty() const
  428.         {
  429.         return Data.IsEmpty();
  430.         }
  431.  
  432.     int IsFull() const
  433.         {
  434.         return 0;
  435.         }
  436.  
  437.     int GetItemsInContainer() const
  438.         {
  439.         return Data.GetItemsInContainer();
  440.         }
  441.  
  442. #if defined( BI_OLDNAMES )
  443.     int isEmpty() const { return IsEmpty(); }
  444.     int isFull() const { return IsFull(); }
  445.     int getItemsInContainer() const { return GetItemsInContainer(); }
  446. #endif  // BI_OLDNAMES
  447.  
  448. protected:
  449.  
  450.     Stk Data;
  451.  
  452. };
  453.  
  454. #if defined( BI_OLDNAMES )
  455. #define BI_StackAsListImp TStackAsListImp
  456. #endif
  457.  
  458. /*------------------------------------------------------------------------*/
  459. /*                                                                        */
  460. /*  template <class T,class Alloc> class TMStackAsList                    */
  461. /*  template <class T,class Alloc> class TMStackAsListIterator            */
  462. /*                                                                        */
  463. /*  Implements a managed stack of objects of type T, using a list as      */
  464. /*  the underlying implementation.                                        */
  465. /*                                                                        */
  466. /*------------------------------------------------------------------------*/
  467.  
  468. template <class T, class Alloc> class TMStackAsListIterator;
  469.  
  470. template <class T,class Alloc> class TMStackAsList :
  471.     public TStackAsListImp<TMListImp<T,Alloc>,T>
  472. {
  473.  
  474.     typedef TStackAsListImp<TMListImp<T,Alloc>,T> Parent;
  475.  
  476. public:
  477.  
  478.     friend class TMStackAsListIterator<T,Alloc>;
  479.  
  480.     typedef void (*IterFunc)(T&, void *);
  481.     typedef int  (*CondFunc)(const T&, void *);
  482.  
  483.     void Push( const T& t )
  484.         {
  485.         Data.Add( t );
  486.         }
  487.  
  488.     T Pop();
  489.  
  490.     const T& Top() const
  491.         {
  492.         PRECONDITION( !Data.IsEmpty() );
  493.         return Data.PeekHead();
  494.         }
  495.  
  496.     void ForEach( IterFunc iter, void *args )
  497.         {
  498.         Data.ForEach( iter, args );
  499.         }
  500.  
  501.     T *FirstThat( CondFunc cond, void *args ) const
  502.         {
  503.         return Data.FirstThat( cond, args );
  504.         }
  505.  
  506.     T *LastThat( CondFunc cond, void *args ) const
  507.         {
  508.         return Data.LastThat( cond, args );
  509.         }
  510.  
  511.     void Flush()
  512.         {
  513.         Data.Flush();
  514.         }
  515.  
  516. #if defined( BI_OLDNAMES )
  517.     void push( const T& t ) { Push(t); }
  518.     T pop() { return Pop(); }
  519.     const T& top() const { return Top(); }
  520.     void forEach( IterFunc iter, void *args )
  521.         { ForEach( iter, args ); }
  522.     T *firstThat( CondFunc cond, void *args ) const
  523.         { return FirstThat( cond, args ); }
  524.     T *lastThat( CondFunc cond, void *args ) const
  525.         { return LastThat( cond, args ); }
  526.     void flush( TShouldDelete::DeleteType = TShouldDelete::DefDelete )
  527.         {
  528.         Flush();
  529.         }
  530.  
  531. #endif  // BI_OLDNAMES
  532. };
  533.  
  534. template <class T, class Alloc> T TMStackAsList<T,Alloc>::Pop()
  535. {
  536.     T t = Top();
  537.     Data.Detach( t );
  538.     return t;
  539. }
  540.  
  541. template <class T,class Alloc> class TMStackAsListIterator :
  542.     public TMListIteratorImp<T,Alloc>
  543. {
  544.  
  545. public:
  546.  
  547.     TMStackAsListIterator( const TMStackAsList<T,Alloc>& s ) :
  548.         TMListIteratorImp<T,Alloc>(s.Data)
  549.         {
  550.         }
  551.  
  552. };
  553.  
  554. #if defined( BI_OLDNAMES )
  555. #define BI_MStackAsList TMStackAsList
  556. #define BI_MStackAsListIterator TMStackAsListIterator
  557. #endif
  558.  
  559. /*------------------------------------------------------------------------*/
  560. /*                                                                        */
  561. /*  template <class T> class TStackAsList                                 */
  562. /*  template <class T> class TStackAsListIterator                         */
  563. /*                                                                        */
  564. /*  Implements a stack of objects of type T, using a list as              */
  565. /*  the underlying implementation and TStandardAllocator as its memory    */
  566. /*  manager.                                                              */
  567. /*                                                                        */
  568. /*------------------------------------------------------------------------*/
  569.  
  570. template <class T> class TStackAsList :
  571.     public TMStackAsList<T,TStandardAllocator>
  572. {
  573. };
  574.  
  575. template <class T> class TStackAsListIterator :
  576.     public TMStackAsListIterator<T,TStandardAllocator>
  577. {
  578.  
  579. public:
  580.  
  581.     TStackAsListIterator( const TStackAsList<T>& s ) :
  582.         TMStackAsListIterator<T,TStandardAllocator>(s)
  583.         {
  584.         }
  585.  
  586. };
  587.  
  588. #if defined( BI_OLDNAMES )
  589. #define BI_StackAsList TStackAsList
  590. #define BI_StackAsListIterator TStackAsListIterator
  591. #endif
  592.  
  593. /*------------------------------------------------------------------------*/
  594. /*                                                                        */
  595. /*  template <class T,class Alloc> class TMIStackAsList                   */
  596. /*  template <class T,class Alloc> class TMIStackAsListIterator           */
  597. /*                                                                        */
  598. /*  Implements a managed stack of pointers to objects of type T,          */
  599. /*  using a linked list as the underlying implementation.                 */
  600. /*                                                                        */
  601. /*------------------------------------------------------------------------*/
  602.  
  603. template <class T,class Alloc> class TMIStackAsListIterator;
  604.  
  605. template <class T,class Alloc> class TMIStackAsList :
  606.     public TStackAsListImp<TMIListImp<T,Alloc>,T *>,
  607.     public TShouldDelete
  608. {
  609.  
  610.     typedef TStackAsListImp<TMIListImp<T,Alloc>,T *> Parent;
  611.  
  612. public:
  613.  
  614.     friend class TMIStackAsListIterator<T,Alloc>;
  615.  
  616.     typedef void (*IterFunc)(T&, void *);
  617.     typedef int  (*CondFunc)(const T&, void *);
  618.  
  619.     ~TMIStackAsList()
  620.         {
  621.         Flush();
  622.         }
  623.  
  624.     void Push( T *t )
  625.         {
  626.         Data.Add( t );
  627.         }
  628.  
  629.     T *Pop();
  630.  
  631.     T *Top() const
  632.         {
  633.         PRECONDITION( !Data.IsEmpty() );
  634.         return Data.PeekHead();
  635.         }
  636.  
  637.     void Flush( DeleteType dt = DefDelete )
  638.         {
  639.         Data.Flush( DelObj(dt) );
  640.         }
  641.  
  642.     void ForEach( IterFunc iter, void *args )
  643.         {
  644.         Data.ForEach( iter, args );
  645.         }
  646.  
  647.     T *FirstThat( CondFunc cond, void *args ) const
  648.         {
  649.         return Data.FirstThat( cond, args );
  650.         }
  651.  
  652.     T *LastThat( CondFunc cond, void *args ) const
  653.         {
  654.         return Data.LastThat( cond, args );
  655.         }
  656.  
  657. #if defined( BI_OLDNAMES )
  658.     void push( T *t ) { Push(t); }
  659.     T *pop() { return Pop(); }
  660.     T *top() const { return Top(); }
  661.     Parent::isEmpty;
  662.     Parent::isFull;
  663.     Parent::getItemsInContainer;
  664.     void flush( DeleteType dt = DefDelete ) { Flush(dt); }
  665.     void forEach( IterFunc iter, void *args )
  666.         { ForEach( iter, args ); }
  667.     T *firstThat( CondFunc cond, void *args ) const
  668.         { return FirstThat( cond, args ); }
  669.     T *lastThat( CondFunc cond, void *args ) const
  670.         { return LastThat( cond, args ); }
  671. #endif  // BI_OLDNAMES
  672. };
  673.  
  674. template <class T, class Alloc> T *TMIStackAsList<T,Alloc>::Pop()
  675. {
  676.     T * t = Top();
  677.     Data.Detach( t );
  678.     return t;
  679. }
  680.  
  681. template <class T,class Alloc> class TMIStackAsListIterator :
  682.     public TMIListIteratorImp<T,Alloc>
  683. {
  684.  
  685. public:
  686.  
  687.     TMIStackAsListIterator( const TMIStackAsList<T,Alloc>& s ) :
  688.         TMIListIteratorImp<T,Alloc>(s.Data)
  689.         {
  690.         }
  691.  
  692. };
  693.  
  694. #if defined( BI_OLDNAMES )
  695. #define BI_MIStackAsList TMIStackAsList
  696. #define BI_MIStackAsListIterator TMIStackAsListIterator
  697. #endif
  698.  
  699. /*------------------------------------------------------------------------*/
  700. /*                                                                        */
  701. /*  template <class T> class TIStackAsList                                */
  702. /*  template <class T> class TIStackAsListIterator                        */
  703. /*                                                                        */
  704. /*  Implements a stack of pointers to objects of type T,                  */
  705. /*  using a linked list as the underlying implementation and              */
  706. /*  TStandardAllocator as its memory manager.                             */
  707. /*                                                                        */
  708. /*------------------------------------------------------------------------*/
  709.  
  710. template <class T> class TIStackAsList :
  711.     public TMIStackAsList<T,TStandardAllocator>
  712. {
  713. };
  714.  
  715. template <class T> class TIStackAsListIterator :
  716.     public TMIStackAsListIterator<T,TStandardAllocator>
  717. {
  718.  
  719. public:
  720.  
  721.     TIStackAsListIterator( const TIStackAsList<T>& s ) :
  722.         TMIStackAsListIterator<T,TStandardAllocator>(s)
  723.         {
  724.         }
  725.  
  726. };
  727.  
  728. #if defined( BI_OLDNAMES )
  729. #define BI_IStackAsList TIStackAsList
  730. #define BI_IStackAsListIterator TIStackAsListIterator
  731. #endif
  732.  
  733. /*------------------------------------------------------------------------*/
  734. /*                                                                        */
  735. /*  template <class T> class TStack                                       */
  736. /*  template <class T> class TStackIterator                               */
  737. /*                                                                        */
  738. /*  Easy names for TStackAsVector and TStackAsVectorIterator.             */
  739. /*                                                                        */
  740. /*------------------------------------------------------------------------*/
  741.  
  742. template <class T> class TStack :
  743.     public TStackAsVector<T>
  744. {
  745.  
  746. public:
  747.  
  748.     TStack( unsigned max = DEFAULT_STACK_SIZE ) :
  749.         TStackAsVector<T>( max )
  750.         {
  751.         }
  752.  
  753. }
  754.  
  755. template <class T> class TStackIterator :
  756.     public TStackAsVectorIterator<T>
  757. {
  758.  
  759. public:
  760.  
  761.  
  762.     TStackIterator( const TStack<T>& a ) :
  763.         TStackAsVectorIterator<T>(a)
  764.         {
  765.         }
  766.  
  767. };
  768.  
  769. #if defined( BI_CLASSLIB_NO_po )
  770. #pragma option -po.
  771. #endif
  772.  
  773. #pragma option -Vo.
  774.  
  775. #endif  // CLASSLIB_STACKS_H
  776.  
  777.