home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tlx501.zip / TEMPLATE / PTRSTACK.CPP < prev    next >
C/C++ Source or Header  |  1996-01-05  |  3KB  |  94 lines

  1. /****************************************************************************
  2.     $Id: ptrstack.cpp 501.0 1995/03/07 12:27:00 RON Exp $
  3.  
  4.     Copyright (c) 1991-95 Tarma Software Research. All rights reserved.
  5.  
  6.     Project:    Tarma Library for C++ V5.0
  7.     Author:    Ron van der Wal
  8.  
  9.     Implementation of class TLPtrStack<T>.
  10.  
  11.     $Log: ptrstack.cpp $
  12.     Revision 501.0  1995/03/07 12:27:00  RON
  13.     Updated for TLX 5.01
  14.     Revision 1.5  1995/01/31 16:30:46  RON
  15.     Update for release 012
  16.     Added partial support for SunPro C++ compiler
  17.     Revision 1.4  1994/09/28  14:41:20  ron
  18.     Removed Macintosh-style #include references
  19.  
  20.     Revision 1.3  1994/09/27  20:27:26  ron
  21.     Changed path separator from / to \
  22.  
  23.     Revision 1.2  1994/09/26  15:33:29  ron
  24.     Changed include file references
  25.  
  26.     Revision 1.1  1994/08/16  18:15:29  ron
  27.     Initial revision
  28.  
  29. ****************************************************************************/
  30.  
  31. #ifndef _TLX_PTRSTACK_CPP
  32. #define _TLX_PTRSTACK_CPP
  33.  
  34. //----- System headers
  35.  
  36. //----- Project headers
  37.  
  38. #ifndef _TLX_PTRARRAY_H
  39. #include <tlx\501\ptrarray.h>    // Class declaration
  40. #endif
  41.  
  42. /*-------------------------------------------------------------------------*/
  43.     template<class T> TLPtrStack<T>::TLPtrStack(size_t aSize, size_t aDelta)
  44.  
  45. /*  Constructor to create stack of specified size; also doubles as default
  46.     constructor.
  47. ---------------------------------------------------------------------------*/
  48. : TLVPStack(aSize, aDelta)
  49. {
  50.     SetDelete(DeleteT);
  51. }
  52.  
  53. /*-------------------------------------------------------------------------*/
  54.     template<class T> TLPtrStack<T>::TLPtrStack(T *aPtr)
  55.  
  56. /*  Constructor that initializes a stack of 1 element.
  57. ---------------------------------------------------------------------------*/
  58. : TLVPStack(aPtr)
  59. {
  60.     SetDelete(DeleteT);
  61. }
  62.  
  63. /*-------------------------------------------------------------------------*/
  64.     template<class T> TLPtrStack<T>::TLPtrStack(T **aStack, size_t aSize)
  65.  
  66. /*  Constructor that initializes a stack from a corresponding C-style
  67.     vector.
  68. ---------------------------------------------------------------------------*/
  69. : TLVPStack((void **)aStack, aSize)
  70. {
  71.     SetDelete(DeleteT);
  72. }
  73.  
  74. /*-------------------------------------------------------------------------*/
  75.     template<class T> TLPtrStack<T>::TLPtrStack(const TLPtrStack<T> &aStack)
  76.  
  77. /*  Copy constructor.
  78. ---------------------------------------------------------------------------*/
  79. : TLVPStack(aStack)
  80. {
  81.     SetDelete(DeleteT);
  82. }
  83.  
  84. /*-------------------------------------------------------------------------*/
  85.     template<class T> void TLPtrStack<T>::DeleteT(void *aPtr)
  86.  
  87. /*  Deletes pointed to object, after the appropriate typecast.
  88. ---------------------------------------------------------------------------*/
  89. {
  90.     delete (T *)aPtr;
  91. }
  92.  
  93. #endif    // _TLX_PTRSTACK_CPP
  94.